Powered by Vanilla 1.1.4.
Installed add-ons.
Okay, i've been designing a system on my home server (using wamp) and everything seems to run peachy. So I uploaded onto my webserver, got the databases installed and shoved the information into the mysql.php, checked everything was okay.
Now whenever mysql_fetch_array($query) is called, it comes up with the following error (Note, both home and new server are using MySQL 5):
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/D/e/s/Desmond1990/html/kb/kb_details.php on line 30
I've checked why this might happen (googled), and is usually due to a faulty SQL statement, however, everything is identical to my home server. The query itself is:
$query=mysql_query("SELECT p.*, pn.pilotName, s.shipName, s.shipIcon, i.itemName, a.allianceName, c.corpName FROM kb_invpilots p LEFT JOIN kb_ships s ON p.shipID=s.shipID LEFT JOIN kb_itemTypes i ON p.weaponID=i.itemID LEFT JOIN kb_alliances a ON p.allianceID=a.allianceID LEFT JOIN kb_corporations c ON p.corpID=c.corpID LEFT JOIN kb_pilots pn ON p.pilotID=pn.pilotID WHERE p.killID='$kid' ORDER BY p.damageDone DESC");
Any ideas why this is going completely higgledy piggledy?
- Des
$query = mysql_query("SQL STATEMENT");
if (!$query) {echo "QUERY FAILED";}
$result = mysql_fetch_array($query);
Try something along those lines to see if the SQL statement is executing correctly first. If it's coming back failed, we know the query is at fault. A casual glance it, I'm not seeing anything obvious, but as an example - $kid might not empty, which could be killing the query.
But I would have thought the script would have died on the first query if there was a problem (i.e the above error handling shouldn't be necessary) - are you sure the query is even being run? That would explain why the resource is invalid too.
Could it be that one environment is set to show warnings and one isn't?
When I've had that warning I think it's been because there weren't any results, and that I placed the relevant code in a suitable 'if' construct.
I wondered that - but why if he's getting a mysql_fetch_array error, then he should also be getting a mysql_query error ![]()
Well I've tried it on my college server and it worked fine there, however, the same site (hosted by godaddy.com) and the query failed. However, when I post the query directly into the phpMyAdmin (replacing '$kid' with the killID) then it works.
This is the code to get it off the url:
$kid=mysql_real_escape_string($_REQUEST['id']);
The first query is:
$query=mysql_query("SELECT k.killID, k.timeStamp, q.pilotName, q.pilotID, c.corpName, a.allianceName, s.shipName, s.shipIcon, ss.solarSystemName, k.damageTaken, count(*) FROM kb_pilots q, kb_solarsystems ss, kb_corporations c, kb_alliances a, kb_ships s, kb_victims k LEFT JOIN kb_invpilots p on p.killID=k.killID WHERE k.killid='$kid' AND q.pilotID=k.pilotID and c.corpID=k.corpID AND a.allianceID=k.allianceID AND s.shipID=k.shipID AND ss.solarSystemID=k.systemID GROUP BY p.killid");
Which is subsequently followed by:
$fetch=mysql_fetch_array($query);
Which generates no error message. So is it something technical that that particular host's MySQL doesn't like?
Des
Have you tried echoing out the entire query, before it runs, so you can see that the killid is being put in correctly?
I can't see anything in the query that would cause an issue from version to version. However, it could be an apache/php setup conflict using $_REQUEST? Hence checking that $kid is being populated correctly.
KillID is entered correctly from the $_REQUEST, but still the errors occur.
And the servers have the same MySQL version? Have you tried running any other - simpler queries?
Yes, I've tried v4.1 and 5 on the webserver. Some other queries work, so maybe it's the structure of those two?
If it works in phpMyadmin, then it should be fine! Very strange - especially as you don't get an error message. Can you fetch a row from the query?
Noope:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/D/e/s/Desmond1990/html/kb/kb_details.php on line 30
Jon, I'm certain that means that there is something not working in the query, which is generating an error, however as the script is not outputting mysql_error() it's not telling you what it is.. Try putting print(mysql_error()); after the query
Just run the following code. It'll tell you exactly what the problem is.
<?php
$query_sql = "SELECT p.*, pn.pilotName, s.shipName, s.shipIcon, i.itemName, a.allianceName, c.corpName FROM kb_invpilots p LEFT JOIN kb_ships s ON p.shipID=s.shipID LEFT JOIN kb_itemTypes i ON p.weaponID=i.itemID LEFT JOIN kb_alliances a ON p.allianceID=a.allianceID LEFT JOIN kb_corporations c ON p.corpID=c.corpID LEFT JOIN kb_pilots pn ON p.pilotID=pn.pilotID WHERE p.killID='$kid' ORDER BY p.damageDone DESC";
$query_res = mysql_query($query_sql);
if (false === $query_res)
{
echo '<h1>The query failed</h1>. The query was: <pre>', $query_sql, '</pre><br />MySQL said: ', mysql_error(), '<br />MySQL error number: ', mysql_errno();
exit();
}
else
{
echo 'The query ran fine.';
}
That's what i said in the first place!
Yeah I must have put it in the wrong place Spode
.
It returned
The query failed
. The query was:
SELECT p.*, pn.pilotName, s.shipName, s.shipIcon, i.itemName, a.allianceName, c.corpName FROM kb_invpilots p LEFT JOIN kb_ships s ON p.shipID=s.shipID LEFT JOIN kb_itemTypes i ON p.weaponID=i.itemID LEFT JOIN kb_alliances a ON p.allianceID=a.allianceID LEFT JOIN kb_corporations c ON p.corpID=c.corpID LEFT JOIN kb_pilots pn ON p.pilotID=pn.pilotID WHERE p.killID='' ORDER BY p.damageDone DESC
MySQL said: Table 'kamin2.kb_itemTypes' doesn't exist
MySQL error number: 1146
I'm looking at my phpMyAdmin now to see why it's saying that.
Aha, it did not like the capitalised 'T' in 'itemTypes'. That simple ![]()
![]()
Capitalisation caught me out once. (Windows/Linux.) ![]()
Thank god for the tab key, that's all I can say.
Erm, quick question, how do you put ',' separators into large integers (1000000 => 1,000,000) ?
Thanks ![]()
1 to 22 of 22