Mysql/php Insert Problem

liunx

Guest
I'm having trouble inserting into my database from my php page. I can connect to the db and select from the db. I've tried deleting the table and creating it again.<br /><br />Nothing is working. Please help.<!--content-->
Can you show what your script is doing?<br />Can you tell us what the error is?<br /><br />I'm not a SQL expert, so I can't help, but I doubt anyone can with the info you've given...<!--content-->
This is how i do it.<br /><br />connecting to database.<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$db = mysql_connect(localhost, $db_username, $db_password);<br />mysql_select_db($db_name);<!--c2--></div><!--ec2--><br />then to insert<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$sql = "INSERT INTO tablename (value1,value2,value3) VALUES ('$var1','$var2','$var3')";<br /> $result = mysql_query($sql);<!--c2--></div><!--ec2--><!--content-->
put your php and sql statements in here along w/ any errors you are getting...<br /><br />chuck<!--content-->
I have a similar question. I created a table, and I want to some information from a form to be added to the db on submitt. What would I have to have in my php file to do this. Can someone spell out for me how to insert to mysql db via a php file. The info that will be inserted is simply a visitors name and email that they insert and submit in my form. Thanks!<!--content-->
 
Top