Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.