473,387 Members | 3,810 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,387 software developers and data experts.

Get error while returning data from mysql

250 100+
When I retriwe data from mysql I got an error saying "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\xxxr\xxx.php on line 34". Please help me.
Expand|Select|Wrap|Line Numbers
  1. $sql="SELECT VehicleMake,VehicleType FROM vehicles WHERE VehicleType=$type AND VehicleMake=$make";
  2.     echo $sql;
  3.     $result = mysql_query($sql);
  4.     while($row = mysql_fetch_array($result))
  5.     {
  6.     echo $row['VehicleMake'] . " " . $row['VehicleType'];
  7.     echo "<br />";
  8.     }
  9.  
  10.  
Sep 24 '09 #1
1 1668
Atli
5,058 Expert 4TB
Hey.

If the mysql_query call fails, it will return FALSE instead of a MySQL resource.
Also, if the query doesn't return a result table (like with INSERT or UPDATE queries), the call will return TRUE, rather then a MySQL resource.

The mysql_fetch_array function only takes a MySQL resource object, so if you don't make sure the query result is a resource, you will get this warning.

Typically, you do something like:
Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($sql);
  2. if($result) {
  3.   while($row = mysql_fetch_array($result)) {
  4.     // etc.
  5.   }
  6. }
Or just
Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($sql) or die(mysql_error());
  2. while($row = mysql_fetch_array($result)) {
  3.     // etc.
  4. }
Sep 24 '09 #2

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
1
by: Maciej Paras | last post by:
Hello! I've written 2 pages: one i HTML format, and second - in ASP. When I'm posting data from HTML page, I receive this error generated by ASP page: Microsoft JET Database Engine (0x80040E14)...
0
by: nthpixel | last post by:
Hey Folks, I am getting the following errors when I try to connect to my db with the MySqlConnection. I added MySql.Data to my Reference list and have the .dll in my bin directory. I also have...
0
by: David P. Donahue | last post by:
Per a previous question I posted on this group, I have a Web Service which returns a DataSet (just a simple SELECT query grabbed from a database). My application calls the web service function and...
0
by: monomaniac21 | last post by:
hi im trying to do a query which takes rows of large amounts of text data and displays them one after another. the size of the fields is causing the page to be massive in size. so to try and...
5
by: kyosohma | last post by:
Hi, I am populating a mySQL database with data from the MS Access database. I have successfully figured out how to extract the data from Access, and I can insert the data successfully into mySQL...
0
by: buk110 | last post by:
Hi guys, I'm really hoping that someone can help me... I have 3 datasets. One that will contain the initial information when I open up the database; one that will pull in information afterwards;...
9
by: Ratfish | last post by:
I'm getting a "2014:: Commands out of sync; you can't run this command now" error on a php page when I try to call a second stored procedure against a MySQL db. Does anyone know why I might be...
8
by: Kjell Pettersen | last post by:
Hello! I have installed PHP and MySql 5.0 on Win XP. Database created ok. Installation ok. PHP scripts runs ok. But when I am trying some mysql calls in the script I get an "Error 500" from...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.