473,395 Members | 1,689 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,395 software developers and data experts.

MySql_fetch_array() error in PHP

In config.php line 28 I have written the following lines.
$query = "SELECT * FROM `users` WHERE username = '".$uname."' AND password = '".$pword."'";
# set a query

$online = mysql_fetch_array(mysql_query($query));

Using MYSQL and PHP in a remote linux server I am getting the following error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/india/public_html/xxxxx/auth/config.php on line 28

Can anybody advice , why I am getting the error.
Nov 21 '06 #1
3 9437
ronverdonk
4,258 Expert 4TB
It most likely means you have an error in the mysql_select because no object was created. Statement of warning: do never nest mysql queries, like you do here, because you can't get to the error that caused it. Instead display the errors and continue depending on the result, like in the following sample:[php]$query = "SELECT * FROM `users` WHERE username = '$uname' AND password = '$pword';
$res = mysql_query($query)
or die("Error in select: " . mysql_error());
if (mysql_num_rows > 0)
$online = mysql_fetch_array($res);
else
echo 'No records available';[/php]
Ronald :cool:
Nov 21 '06 #2
Nert
64
hi Sir Ronald,

i just edited something on your post at the line "if(mysql_num_rows > 0)". (^_^)

[php]
$query = "SELECT * FROM `users` WHERE username = '$uname' AND password = '$pword';
$res = mysql_query($query)
or die("Error in select: " . mysql_error());
if (mysql_num_rows($res) > 0)
$online = mysql_fetch_array($res);
else
echo 'No records available';[/php]


--nert
Nov 22 '06 #3
ronverdonk
4,258 Expert 4TB
hi Sir Ronald,

i just edited something on your post at the line "if(mysql_num_rows > 0)". (^_^)

[php]
$query = "SELECT * FROM `users` WHERE username = '$uname' AND password = '$pword';
$res = mysql_query($query)
or die("Error in select: " . mysql_error());
if (mysql_num_rows($res) > 0)
$online = mysql_fetch_array($res);
else
echo 'No records available';[/php]


--nert
You are right, thanks.

Ronald :cool:
Nov 22 '06 #4

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
1
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
5
by: yashu0209 | last post by:
I have an error occurring when i try to compile the program and the error is: D:\Program Files\visual studio 6.0\MSDev98\MyProjects\GLEnabledView\GLNew.cpp(164) : error C2653: 'CGLEnabledView' :...
2
by: randa zaghdan | last post by:
Hi I have a problem with my program in vc 2008 When I compile it, the following errors are listed. I try to resolve it but no hope Does any one can help me ? thanks . Linking......
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
0
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...

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.