Jump to content

php/mysql code won't update table data


tracy

Recommended Posts

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.');
}
Link to comment
https://forums.phpfreaks.com/topic/29154-phpmysql-code-wont-update-table-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.