Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Fatal error: Call to undefined function mysqli_num_row()
Closed Thread
Old 05-06-2007, 05:53 PM   #1 (permalink)
 
True Techie

Join Date: Feb 2006

Posts: 228

selina

Send a message via ICQ to selina Send a message via Yahoo to selina
Default Fatal error: Call to undefined function mysqli_num_row()

hi,
i'm pretty new to the PHP...

I have a form which takes user's name and then, run a query to see if their names exist in the database. but i keep getting the following error when i try to run it:

Fatal error: Call to undefined function mysqli_num_row() in /var/www/wedding/rsvp.php on line 13

the web server is running on UNIX. I dont' know what more information is needed....

the code is:

<?php

$mysqli = mysqli_connect("localhost", "user", "password", "database");



/* check connection */

if (!$mysqli) {

die ('could not connect: ' . mysql_error());

}

else {

printf("name to find is " .$_POST["name"]."<br />");

$namesearch_sql="SELECT * FROM tbl_guests WHERE guest_name = '".$_POST['name']."'";

$namesearch_res=mysqli_query($mysqli, $namesearch_sql) or die(mysqli_error($mysqli));



if (mysqli_num_row($namesearch_res) < 1) {

printf("no name");

}

else {

while ($new = mysqli_fetch_array($namesearch_res)) {

$newname=$new['guest_name'];

printf("name: ".$newname);

}

}



/* close connection */

mysqli_close($mysqli);

}

?>
selina is offline  
Old 05-07-2007, 02:10 AM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default Re: Fatal error: Call to undefined function mysqli_num_row()

what is mysqli ? The error your getting means that the parser cannot find the function you're calling. The only way I know how to connect to mysql through php is the mysql_connect() method.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 05-07-2007, 02:11 PM   #3 (permalink)
 
True Techie

Join Date: Feb 2006

Posts: 228

selina

Send a message via ICQ to selina Send a message via Yahoo to selina
Default Re: Fatal error: Call to undefined function mysqli_num_row()

thanks for your reply.
mysqli is available for PHP 5. i figured out what the problems was for the posted codes. it was as simple as changing mysqli_num_row() to mysqli_num_rowS()...

anyways, i have another problem for PHP4, maybe you can help me.
i'm getting the error message:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in //path/rsvp.php on line 9

for the code:
<?php
$mysql = mysql_connect("localhost", "userid", "pw", "databse");
/* check connection */
if (!$mysql) {
die ('could not connect: ' . mysql_error());
}
else {
$display_block="name to find is \"" .$_POST["name"]."\"<br />";
$namesearch_sql="SELECT * FROM tbl_guests WHERE guest_name LIKE '".$_POST['name']."%'";
$namesearch_res=mysql_query($mysql, $namesearch_sql) or die(mysql_error($mysql));
if (mysql_num_rows($namesearch_res) < 1) {
$display_block .= "no name";
}
else {
$display_block="name found.";
}
/* close connection */
mysql_close($mysql);
}
?>

<html>
<head>
<title>RSVP</title>
</head>
<body>
<h2> RSVP </h2>
<?php echo "$display_block"; ?>
</body>
</html>
selina is offline  
Old 05-07-2007, 02:18 PM   #4 (permalink)
Yek
 
T.F's Resident Cool Guy...

Join Date: Aug 2006

Posts: 1,625

Yek is on a distinguished road

Send a message via AIM to Yek Send a message via MSN to Yek Send a message via Yahoo to Yek Send a message via Skype™ to Yek
Default Re: Fatal error: Call to undefined function mysqli_num_row()

You answered your own question , you cannot use mysqli in version 4 , thats the way i understood it. Therefor it is not a valid resource
Yek is offline  
Old 05-07-2007, 02:39 PM   #5 (permalink)
 
True Techie

Join Date: Feb 2006

Posts: 228

selina

Send a message via ICQ to selina Send a message via Yahoo to selina
Default Re: Fatal error: Call to undefined function mysqli_num_row()

but it seems like i'm getting the error for this code:
$namesearch_res=mysql_query($mysql, $namesearch_sql) or die(mysql_error($mysql));

in PHP5, it works fine (i need to replace "mysql" with "mysqli" tho)... does PHP4 works differently to run a query?
selina is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On