Jump to content

[SOLVED] checking if sql queury was successfull?


darksniperx

Recommended Posts

$result = mysql_query("SELECT * FROM feed WHERE feed_id = '$id'");
if(!$result)
{
die("query unsuccessfull");
}
else
{
echo'queury successfull';
}

something along these lines, but to be able to check any kind of query, add, delete, update,...

the example above does not work me.

<?php

  $sql = "SELECT * FROM feed WHERE feed_id = '$id'";
  if ($result = mysql_query($sql)) {
    // query was successfull.
    if (mysql_num_rows($result)) {
      // rows were found, fetch array and display result.
    } else {
      echo "No rows found";
    }
  } else {
    echo "Query failed<br />$sql<br />" . mysql_error();
  }

?>

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.