473,545 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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">R egistered Users</h1>';

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

// Make the query.
$query = "SELECT CONCAT(last_nam e, ', ', first_name) AS name, DATE_FORMAT(reg istration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_da te 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_arr ay($result, MYSQL_ASSOC)) {
echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['dr'] . '</td></tr>
';
}

echo '</table>';

mysql_free_resu lt ($result); // Free up the resources.

} else { // If it did not run OK.
echo '<p class="error">T here 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 18894
ronverdonk
4,258 Recognized Expert Specialist
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 New Member
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">R egistered Users</h1>';

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

// Make the query.
$query = "SELECT CONCAT(last_nam e, ', ', first_name) AS name, DATE_FORMAT(reg istration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_da te ASC";
$result = mysql_query($qu ery) 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_arr ay($result)) {
echo "<tr>
<td align='left'>" .$row['name'] ."</td>
<td align='left'>" .$row['dr'] ."</td>
</tr>";
}
echo "</table>";

mysql_free_resu lt ($result); // Free up the resources.

} else { // If it did not run OK.
echo '<p class="error">T here 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
7962
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, Quantity FROM restorder_item WHERE Order_Number =58 The code I use to do it is.... $query = "select Menu_Item, Quantity from restorder_item"; $query .=...
2
4235
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 file.php on line 46. But I'am sure that the code is good, because I have use the code very much. Create a connection is working, mysql_query is working...
3
3423
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array(): ============================================================== In the past i use my code/script work fine with Mandrake 9.1 - 10.1 ( + apache ,mysql ) Now i move to redhat EL4 with the same...
9
7410
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: " . mysql_error()); mysql_select_db("my_dbf") or die("Grr");
3
3904
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"> <div class="boxhead" style="text-align:center;"> <strong>Menu</strong> </div> <br /> <?php require ('includes/db_conn.inc.php'); $query =...
4
7823
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 fields Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34 Sorry...
2
16909
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 not a valid MySQL result resource in /home/jplane/certcent/phpweb/quiz/index.php on line 21 PHP CODE:
1
2695
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 line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
4
5020
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 check login details. Here is the code for the pages that i used. main_login.php <html> <body>
2
16966
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: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\mysql_class_2.php on line 45. Can anyone help me? ...
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.