Jump to content

Checking if query has passed of not


alexville

Recommended Posts

Please read some MySQL tutorials. If you're new to PHP/MySQL please post in the newbie topic area instead.

Basic example:
[code]
$sql = 'Update ....';
$result = mysql_query($sql);

if ($result)
   echo 'Row has been updated';
else
   echo 'Could not update the row. Error: ', mysql_error();
[/code]

Look at the FAQ post at the top of the newbie topic area.
It doesn't work with mine... Can you take a look at it?

[code]mysql_select_db("alexg_web",$dbcnx);
$resultupdateguess = @mysql_query("UPDATE whoamipeople SET guessed = '$newguessed' WHERE Firstname = '$guessfirstname'");[/code]

If the data can NOT be updated (because the Firstnames dont match) i want it to show a message.
I've already given you an example. Please try and apply what people share on this forum to you. Here's another:

[code]
// Connect to MySQL first!
$dbcnx = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$dbcnx) {
   die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db("alexg_web", $dbcnx);
if (!$db_selected) {
   die ('Could not select DB: ' . mysql_error());
}

$resultupdateguess = mysql_query("UPDATE whoamipeople SET guessed = '$newguessed' WHERE Firstname = '$guessfirstname'");

if ($resultupdateguess)
   echo 'Row has been updated';
else
   echo 'Could not update the row. Error: ', mysql_error();
[/code]

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.