sketcht Posted August 2, 2009 Share Posted August 2, 2009 I'm going a little nuts over this simple code, if someone could check this over I would very much appreciate it. I have Table named Clients I am trying to insert some posted vars into said table... but it's not doing anything. php v5.2.9 mySQL v5.0.75 Table: Clients --------------------------------------------------------------------------- EmailAddress UserPassword FirstName LastName BusinessName $sql="INSERT INTO Clients(EmailAddress, UserPassword, FirstName, LastName, BusinessName) VALUES('$email_address', '$user_password', '$first_name', '$last_name', '$business_name')"; $result=mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/168542-solved-insert-into-trouble/ Share on other sites More sharing options...
smerny Posted August 2, 2009 Share Posted August 2, 2009 $result=mysql_query($sql) or die ('SQL Error: ' . mysql_error()); do this to see the error Link to comment https://forums.phpfreaks.com/topic/168542-solved-insert-into-trouble/#findComment-889078 Share on other sites More sharing options...
ldougherty Posted August 2, 2009 Share Posted August 2, 2009 Another good way to see the error is via a tool such as phpmyadmin. You can run the query via the GUI and see the error it spits out. If the query itself works fine in phpmyadmin then it is likely the values are not coming into the script as expected. Link to comment https://forums.phpfreaks.com/topic/168542-solved-insert-into-trouble/#findComment-889151 Share on other sites More sharing options...
sketcht Posted August 3, 2009 Author Share Posted August 3, 2009 I apprieciate the responses guys. I'll check phpMyAdmin with the query, Then my .swf where the vars are coming from. I assume i can echo the mysql error and assign it to a var, such as or die(echo "success= 'SQL Error' . mysql_error()"); as i can check "success" from my .swf if i echo as such echo "success=yes"; Link to comment https://forums.phpfreaks.com/topic/168542-solved-insert-into-trouble/#findComment-889903 Share on other sites More sharing options...
smerny Posted August 3, 2009 Share Posted August 3, 2009 you dont need the echo after die( Link to comment https://forums.phpfreaks.com/topic/168542-solved-insert-into-trouble/#findComment-889945 Share on other sites More sharing options...
sketcht Posted August 5, 2009 Author Share Posted August 5, 2009 Thanks for the help guys. ended up the problem was not having quotes around my vars in my php file. doh this works, but it was not what was in my php file. $sql="INSERT INTO Clients(EmailAddress, UserPassword, FirstName, LastName, BusinessName) VALUES('$email_address', '$user_password', '$first_name', '$last_name', '$business_name')"; $result=mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/168542-solved-insert-into-trouble/#findComment-891499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.