Jump to content

Problems updating the database


niza

Recommended Posts

[code]$connection = mysql_connect($host, $user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database.");
$sql = "UPDATE ad SET adName='$adName', adInfo='$adInfo', adPrice='$adPrice' WHERE adID='21'";
$result = mysql_query($sql) or die("Couldn't modify database.");
mysql_close($connection); [/code]

This is the error I get: Couldn't modify database. Anyone knows what is happening and why I cannot update the database?

I checked all tables in the database for spelling mistakes and the variables. But I found no mistakes.
Link to comment
Share on other sites

Never mind. The variables were not being passes. I used this to get the variables:

$adName = $_POST['adName'];
$adInfo = $_POST['adInfo'];

And now it works.

Is there any way I can get the variables through a loop or something rather then manually give each variable a value?
Link to comment
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.