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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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]
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.