Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7680433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:48+00:00 2026-05-31T18:06:48+00:00

Assume the field data type is varchar When i add a integer in it,

  • 0

Assume the field data type is varchar
When i add a integer in it, it will post and add it as string,

and assume the field data type is int
When i add a varchar in it, it will post and add it as “0” in the database,

So are there anyway to check whether the datatype is equal to what is in the database?

All i want to check is varchar, integer and boolean

Thank you

//get column name

try {
    $q = $conn->prepare("DESCRIBE subscriber");
    $q->execute();
    $tableField = $q->fetchAll(PDO::FETCH_COLUMN);
        }
    catch(PDOException $e)
    {
    die ($e->getMessage()."<a href='view.php' onClick='window.location.reload()'> Back</a>"); 
    }  

        foreach ($tableField as $set)
        {$counter=0;
        //if ($set!='Email')
        $subCol[]=$set; //column name
        $noOfColumn[]=$counter; //how much column
        }


//get column datatype           

foreach ($noOfColumn as $set)
{
try{
$sql ='SELECT  s.*
    FROM  subscriber s,list_sub ls
    where ls.ListID = ?
    AND  s.SubID=ls.SubID
    ';

$select = $DB->query($sql);
$meta = $select->getColumnMeta($set);
$dataType[]=$meta[$subCol['$set']]; //an arrary of datatype



}
catch(PDOException $e)
    {
    die ($e->getMessage().'<a href="viewAll.php"> Back</a>'); 
    }
}

//assume input1='int' , input2='varchar' ,input3='bool'
//column name in database = input box name


foreach ($dataType as $compare)
{if($compare[$subCol['FieldName']]==gettype(mixed $input1))
echo "ok, same type";
else
echo "no, not same type";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:06:49+00:00Added an answer on May 31, 2026 at 6:06 pm

    I see no point in such automated verifications.
    Especially the former one.

    You have to implement application-level verifications, checking if value meets certain conditions.

    BTW, Mysql doesn’t have boolean field type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

assume a data structure Person used for a contact database. The fields of the
Assume I created a type as follows: data RequestAck = RequestAck { ackOK ::
Assume you are doing something like the following List<string> myitems = new List<string> {
I am using QSqlQuery to insert data into a MySQL database. Currently all I
I have these four table assume that ring table consist of five fields(jewelry_id,ring_id,image,type,brand_id) Note
I have a double-precision floating point field in my database that stores seconds past
We have the following class public class TemporalData<T> { private T data; private String
Assume you have some objects which have several fields they can be compared by:
Assume java 1.6 and leopard. Ideally, it would also be nice to get a
(assume php5) consider <?php $foo = 'some words'; //case 1 print these are $foo;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.