tracy Posted December 1, 2006 Share Posted December 1, 2006 This insert file won't insert the data into the mysql table...any ideas? Of course, the username and password are not shown here...thanks for any help. By the way, I have tried to get phpmyadmin to write it, tried variations of the / before the ' and nothing seems to work. I think I am connecting to the db...the code just isn't working. Kind of new to php, so please keep it simple...thanks again.this is the code for the insert.php:$dbh=mysql_connect ("localhost", "usernamehere", "passwordhere") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ('invent_inventory'); $sql = 'INSERT INTO `inventory` (`stock`, `year`, `make`, `model`, `price`, `miles`, `photo1`, `photo2`, `photo3`, `photo4`, `photo5`, `photo6`, `description`) VALUES ('".mysql_real_escape_string($_POST['stock'])."','".mysql_real_escape_string($_POST['year'])."','".mysql_real_escape_string($_POST['make'])."','".mysql_real_escape_string($_POST['model'])."','".mysql_real_escape_string($_POST['price'])."','".mysql_real_escape_string($_POST['miles'])."','".mysql_real_escape_string($_POST['photo1'])."','".mysql_real_escape_string($_POST['photo2'])."','".mysql_real_escape_string($_POST['photo3'])."','".mysql_real_escape_string($_POST['photo4'])."','".mysql_real_escape_string($_POST['photo5'])."','".mysql_real_escape_string($_POST['photo6'])."','".mysql_real_escape_string($_POST['description'])."');if($res = mysql_query($sql)){ echo('one record added'); } else { echo('There was a problem inserting data.'); } Quote Link to comment https://forums.phpfreaks.com/topic/29154-phpmysql-code-wont-update-table-data/ Share on other sites More sharing options...
craygo Posted December 1, 2006 Share Posted December 1, 2006 try this and see what you get[code]if($res = mysql_query($sql)){ echo('one record added'); } else { echo('There was a problem inserting data. Error:'.mysql_error()); }[/code]Ray Quote Link to comment https://forums.phpfreaks.com/topic/29154-phpmysql-code-wont-update-table-data/#findComment-133659 Share on other sites More sharing options...
tracy Posted December 1, 2006 Author Share Posted December 1, 2006 I tried it and got an error in the first part of what you sent me. Says error line 13, which is that line...right where I started with your code...any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/29154-phpmysql-code-wont-update-table-data/#findComment-133663 Share on other sites More sharing options...
Philip Posted December 1, 2006 Share Posted December 1, 2006 What is the exact error (copy and paste)and, it might just be me, but I think it has something to do with the quotes, and the periods inside of the Value() set. Quote Link to comment https://forums.phpfreaks.com/topic/29154-phpmysql-code-wont-update-table-data/#findComment-133700 Share on other sites More sharing options...
tracy Posted December 1, 2006 Author Share Posted December 1, 2006 problem was '' vs 'thanksproblem solved Quote Link to comment https://forums.phpfreaks.com/topic/29154-phpmysql-code-wont-update-table-data/#findComment-133702 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.