mysql errors

I am posting again to see if I can get another idea where to go with this one. My DB is set up and all my information is set to be called properly. I am not sure what could be causing the problem or what road I could head down to figure out the fix anymore.

The only thing I can figure is that the syntax is not right since everything worked on a linux server but it’s not working on a windows server. So, if anyone could point me in the right direction I would appreciate the help. Below is the code that resutls in the following errors:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsordersclassesorder.php on line 1416

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsordersclassesorder.php on line 1419

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsordersclassesorder.php on line 1422

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsordersclassesorder.php on line 1429

[code]function orderSummary ( $orderID, $userID ) {
	$queryOrder = "select * from orders where ID=".$orderID;
	$orderInfo = mysql_fetch_array ( mysql_query ( $queryOrder ) );

	$queryStatus = "select name from status where ID=".$orderInfo['statusID'];
	$orderStatus = mysql_fetch_array ( mysql_query ( $queryStatus ) );

	$queryRequestor = "select firstName, lastName from teamMembers where ID=".$orderInfo['requestorID'];
	$requestorInfo = mysql_fetch_array ( mysql_query ( $queryRequestor ) );

	$queryUserInfo = "select * from teamMembers where ID=".$userID;
	$userInfo = mysql_fetch_array ( mysql_query ( $queryUserInfo ) );

	$queryTLInfo = "select * from teamMembers where ID=".$orderInfo['approverID'];
	$resultTLInfo = mysql_query ( $queryTLInfo );
	$tlInfo = mysql_fetch_array ( $resultTLInfo );[/code]

chilis3,

Are you making the database connection before this function is called?

-boobay

At the very top of that page of code is this information:

include “admin/dbinfo.php”;

This calls to the database information so it should have access to the DB from there on for this page.

Are any other pages having issues with database calls?

Ensure that your database connection is not just a link to the database server but that it specifies the database that you want to use.

Also consider using echo mysql_error(); after the lines where each query is made.

Something about the query or connection is failing. The first one is probably cascading to the subsequent ones. MYSQL_ERROR will give you more detail (such as invalid query, database not selected, etc…)

The only other thing I can see is that your ID must be numeric otherwise you need to enclose it in quotes

i.e.
$queryOrder = ‘SELECT * FROM orders WHERE id="’.$orderID.’"’;

Color added for visual clarity

Ok, I entered the text to resolve the error and I am getting:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

Here is line 1-3

<?php include "admin/dbinfo.php"; class Order {

Also, I am not sure about any other pages at this time. I am trying to get one section working at a time so that I can maybe transfer that information to problems in other areas. It’s been working so far and I am in no doubt that I am probably having other DB problems I just don’t fully know how to get them to present.

That error message is a result of the MYSQL_ERROR function and the LINE 1 is of your SQL Statement not of the script it self.

Try modifying the mysql_error() statement as follows:
echo “Query is:”.$queryOrder.“
Mysql ERROR is:”.mysql_error()."
";

That way you can Look at the SQL statement AND see the error message. It may become more obvious than (or maybe not) but then it’s easier to diagnose what’s happening.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsordersclassesorder.php on line 1420
Query is:select name from status where ID=
Mysql ERROR is:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

Is the error now. It looks like the server this is being migrated from had an older version of mysql installed so now I have to correct syntax for this version? Would this information appear correct to everyone?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsordersclassesorder.php on line 1420
This one is the PHP Error (which started this post)

select name from status where ID=
This is your SQL statement which is actually the heart of the problem (now that I see it)

Mysql ERROR is:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
This is the MYSQL Error message which was generated because your query failed.

It looks like the server this is being migrated from had an older version of mysql installed so now I have to correct syntax for this version? Would this information appear correct to everyone?
NO the problem is your QUERY. Apparently you have no data in your variable $orderID. Notice your SQL statement has an ID= and it’s BLANK? That is the problem.

You need a value there or you need to not have it in your where clause .

Examples of VALID SQL statements (assuming the ID is an integer value)

[ul]select name from status where ID=1
select name from status where ID is NULL
select name from status where ID = “”
select name from status[/ul]

All of them could be considered as valid. If you are going to have a WHERE clause you must have a value for the items in the where clause.

I hope that makes sense.

AKA DEBUGGING.
Where are you calling the orderSummary() function? Are you giving it parameters? If so, are they filled with values, and for that matter, with values of the expected type?

Sponsor our Newsletter | Privacy Policy | Terms of Service