...

View Full Version : Resolved Trouble with "mysql_fetch_object():"



Dan13071992
11-23-2011, 10:26 PM
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 20

Notice: Trying to get property of non-object in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 25

Notice: Trying to get property of non-object in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 28

Notice: Trying to get property of non-object in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 33

Notice: Trying to get property of non-object in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 43

Notice: Trying to get property of non-object in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 45

Notice: Trying to get property of non-object in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 50

hi guys i believe these errors are appearing because of this line of code:


$querylocation=mysql_query("SELECT u.*,r.country FROM users AS u LEFT JOIN countries AS r ON u._countryid=r.id WHERE u.username='$fetch->username' LIMIT 1");
$fetchlocation = mysql_fetch_object($querylocation);

$query_countryid=mysql_query("SELECT u.*,r._countryid FROM bf AS u LEFT JOIN countries AS r ON u._countryid=r.id WHERE u.country='$fetchlocation->country'");
$fetch_countryid = mysql_fetch_object($query_countryid);



what i am trying to do is collect the users country and place it into the bf fetch information, the location of the bf changes depending on which country the user is in. i know the first part of the code works fine:


$querylocation=mysql_query("SELECT u.*,r.country FROM users AS u LEFT JOIN countries AS r ON u._countryid=r.id WHERE u.username='$fetch->username' LIMIT 1");
$fetchlocation = mysql_fetch_object($querylocation);


however its the second part that is giving me the error:


$query_countryid=mysql_query("SELECT u.*,r._countryid FROM bf AS u LEFT JOIN countries AS r ON u._countryid=r.id WHERE u.country='$fetchlocation->country'");
$fetch_countryid = mysql_fetch_object($query_countryid);

thanks in advance if you can help me :)

tangoforce
11-23-2011, 10:48 PM
Always, always, always use mysql_error() to find out what is wrong with your SQL.

Dan13071992
11-23-2011, 10:49 PM
Always, always, always use mysql_error() to find out what is wrong with your SQL.

im using

ini_set('display_errors', 1);
error_reporting(E_ALL);

Fou-Lu
11-23-2011, 11:19 PM
This is a SQL error though, not a PHP one. Error reporting only reports on the language.
The problem is your query has failed. You need to add or die(mysql_error()); to the ending of a mysql_query call so you can determine why. In PHP world, there is no problem.

Dan13071992
11-23-2011, 11:26 PM
using what you said im now getting this error:


Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 20
Unknown column 'r._countryid' in 'field list'


however i know the column exists because i can see it

tangoforce
11-24-2011, 01:13 AM
im using

ini_set('display_errors', 1);
error_reporting(E_ALL);


Along with what Fou has said, note that I said SQL not php :thumbsup:

Dan13071992
11-24-2011, 01:21 AM
i feel like such an idiot, and I feel like I have wasted your time, sorry, I found out the problem isnt that I need to call the query like that, instead all i needed was to call where the user was, not where the bf was.

Sorry once again. but thank you for your help, It was all thanks to your mysqlerror function that I found it :) thanks again

tangoforce
11-24-2011, 01:37 AM
i feel like such an idiot, and I feel like I have wasted your time

Neither of which are true. We're all here to help each other and point your errors out to help you.

XterM
11-24-2011, 08:06 AM
using what you said im now getting this error:


Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/tacticsc/domains/360-tactics.co.uk/public_html/crimewave/bf2.php on line 20
Unknown column 'r._countryid' in 'field list'


however i know the column exists because i can see it

make sure culumn "_countryid" exists in table countries. also make sure it column name written correctly. I am worried about "underline" in your column name. :thumbsup:

lets we see your table structure.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum