Jump to content


Photo

Can't add record to db table?


  • Please log in to reply
3 replies to this topic

#1 doni49

doni49
  • Members
  • PipPipPip
  • Advanced Member
  • 515 posts
  • LocationCentral MO

Posted 21 January 2006 - 10:16 PM

$query = INSERT INTO users (username, first_name, last_name, password, registration_date, phone_num, secretAU, secretQU, secretAP, secretQP, fax_num, email) VALUES ('doni49', 'Don', 'Ireland', PASSWORD('kirsten'), NOW(), '215-932-2391', 'Jennifer', 'What was your first girlfriend\'s name?', 'Deland', 'What is your father\'s middle name?', '508-546-0464', 'don@donireland.com')

$result = @mysql_query ($query); // Run the query.

It fails to add the data to the DB. I've confirmed that the script IS logging in. The user has "ALL PRIVILEDGES" to the DB. The "result" variable ends up with NO value.

echo '<br><br><br>Hi<br>' . $result . 'Bye<br><br><br>';

The above shows this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]


Hi
Bye
[/quote]

I THINK it might have something to do with the "Collation" in the user table fields, when I try to remove the collation via phpMyAdmin, it says they were altered. But then when I check the user table structure, the collation is back.

I've attached an image showing the table structure in phpMyAdmin.
[img src=\"http://67.62.63.125/usertable.jpg\" border=\"0\" alt=\"IPB Image\" /]

Can someone help me track this down?

TIA1
Don

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 January 2006 - 07:11 PM

Try the following (as per LazyJones):

$result = mysql_query($query) or die ("ERROR: ".mysql_error()." with query: $query");

Maybe you'll get some more info about the problem.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 doni49

doni49
  • Members
  • PipPipPip
  • Advanced Member
  • 515 posts
  • LocationCentral MO

Posted 24 January 2006 - 09:05 PM

Thanks for taking the time to reply. I found it last night. I don't remember removing it, but one of the fields that the posted script was trying to add data to was not there. Therefore it was failing.

The only thing I could find that looked out of the ordinary was that "collation" stuff--Latin Swedish?

Rather than post back here saying "never mind", I figured I'd let the thread die.
Don

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 January 2006 - 11:54 PM

Glad you go it working -- btw, latin_swedish is the default character set/collation, at least in MySql 4. It looks funny, but it's fine.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users