Jump to content

somebody check pls


narjis

Recommended Posts

I am unable to execute mysql_num_rows properly in this program.

<?php
$link=mysql_connect("localhost","root","");
$db = mysql_select_db("myDB",$link);
$result = mysql_query("SELECT * FROM jobs WHERE jobType=abc"); 
$num = mysql_num_rows($result);
echo "Found $num records";
?>

error is mysql_num_rows() expects parameter 1 to be resource

Link to comment
https://forums.phpfreaks.com/topic/237028-somebody-check-pls/
Share on other sites

You should always check your queries for success before using any data they might return.

 

if ($result = mysql_query("SELECT * FROM jobs WHERE jobType = 'abc'")) { 
    $num = mysql_num_rows($result);
    echo "Found $num records";
}

 

Note I also fixed your query which was missing quotes around the string 'abc'.

Link to comment
https://forums.phpfreaks.com/topic/237028-somebody-check-pls/#findComment-1218344
Share on other sites

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.