PHP-General - I get this error: Column count doesn't match value count at row 1
Discuss I get this error: Column count doesn't match value count at row 1 in the PHP Development forum on Dev Shed. I get this error: Column count doesn't match value count at row 1 PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Posts: 2,867
Time spent in forums: 1 Year 1 Week 5 Days 9 h 6 m 6 sec
Reputation Power: 581
What does this give you:
PHP Code:
$q = "INSERT INTO `auth` (`username`,`guid`) VALUES ('".$_GET["username"].",".$_GET["guid"]."')";
echo $q;
I'm betting one of the $_GET values is null. Also I sure hope you are using prepared statements for that query or you are leaving yourself wide open to injections.
P.S. Note the use of [ PHP ] tags.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.
Posts: 377
Time spent in forums: 1 Week 3 h 27 m 44 sec
Reputation Power: 293
Quote:
Originally Posted by requinix
I take it you guys haven't noticed it's his own thread and that he was yelling at himself?
It is also possible he meant to say "FIXED IT NOW!!!"... just sayin...
Incase he hasn't fixed it, the issue is a couple of missing apostrophes (I am assuming this is what Jaques1 had as a solution).
PHP Code:
//his code
$q = "INSERT INTO `auth` (`username`,`guid`) VALUES ('".$_GET["username"].",".$_GET["guid"]."')";
//fixed code:
$q = "INSERT INTO `auth` (`username`,`guid`) VALUES ('".$_GET["username"]."','".$_GET["guid"]."')";
edit: Also, using $_GET directly into db queries leaves you very open to SQL injection. It would be worth looking into using prepared statements instead, or at least sanitising your input data.
__________________
"Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002