473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/scripts/07/view_users.php on line 15

Can anyone spot my error?!? Thanks.

<?php # Script 7.6 - view_users.php (2nd version after Script 7.4)
// This script retrieves all the records from the users table.

$page_title = 'View the Current Users';
include ('./includes/header.html');

// Page header.
echo '<h1 id="mainhead">Registered Users</h1>';

require_once ('./mysql_connect.php'); // Connect to the db.

// Make the query.
$query = "SELECT CONCAT(last_name, ', ', first_name) AS name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_date ASC";
$result = @mysql_query ($query); // Run the query.
$num = mysql_num_rows($result);

if ($num > 0) { // If it ran OK, display the records.

echo "<p>There are currently $num registered users.</p>\n";

// Table header.
echo '<table align="center" cellspacing="0" cellpadding="5">
<tr><td align="left"><b>Name</b></td><td align="left"><b>Date Registered</b></td></tr>
';

// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['dr'] . '</td></tr>
';
}

echo '</table>';

mysql_free_result ($result); // Free up the resources.

} else { // If it did not run OK.
echo '<p class="error">There are currently no registered users.</p>';
}

mysql_close(); // Close the database connection.

include ('./includes/footer.html'); // Include the HTML footer.
?>
Nov 9 '06 #1
2 18886
ronverdonk
4,258 Expert 4TB
When you suppress the error, you waill not get an error message. Replace with

[php]$result = mysql_query ($query)
or die("Query error: ". mysql_error());[/php]
and see what the message says.

Next time put your code between tags as stated in the Posting Guidelines!!

Ronald :cool:
Nov 9 '06 #2
Nert
64
try this one, if it didn't work i don't know what your problem was hehe(^_^)..

<?
$page_title = 'View the Current Users';
include ('./includes/header.html');

// Page header.
echo '<h1 id="mainhead">Registered Users</h1>';

require_once ('./mysql_connect.php'); // Connect to the db.

// Make the query.
$query = "SELECT CONCAT(last_name, ', ', first_name) AS name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_date ASC";
$result = mysql_query($query) or die(mysql_error()); // Run the query.
$num = mysql_num_rows($result);
echo "<p>There are currently $num registered users.</p>\n";

if($num != 0){
// Table header.
echo "<table align='center' cellspacing='0' cellpadding='5'>
<tr>
<td align='left'><b>Name</b></td>
<td align='left'><b>Date Registered</b></td>
</tr>";

// Fetch and print all the records.
while ($row = mysql_fetch_array($result)) {
echo "<tr>
<td align='left'>" .$row['name'] ."</td>
<td align='left'>" .$row['dr'] ."</td>
</tr>";
}
echo "</table>";

mysql_free_result ($result); // Free up the resources.

} else { // If it did not run OK.
echo '<p class="error">There are currently no registered users.</p>';
}

mysql_close(); // Close the database connection.

include ('./includes/footer.html'); // Include the HTML footer.
?>

--nert
Nov 10 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Noel Wood | last post by:
Hello I keep getting a warning ... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in "name of my php file" when I run this query.... SELECT Menu_Item,...
2
by: Willem Berendsen | last post by:
Hello, I setting up my mysql-server and php on IIS6 and it works almost fine. But I got the next error: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in...
3
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array():...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
3
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu">...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
2
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
4
by: fisherd | last post by:
When i run this code, i keep getting this message; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\checklogin.php on line 26 i use this code to...
2
by: poreko | last post by:
I am connecting to my database using Object oriented PHP. My query is returning results but at the end of my table,at the bottom of the page I keep having this error when I run my program: Warning:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.