Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts

    Trouble with "mysql_fetch_object():"

    PHP Code:
    Warningmysql_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:

    PHP 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:

    PHP 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); 
    however its the second part that is giving me the error:

    PHP Code:
    $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
    Last edited by Dan13071992; 11-24-2011 at 09:23 AM.
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,479
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Always, always, always use mysql_error() to find out what is wrong with your SQL.
    I can't really think of anything to write here now...

  • Users who have thanked tangoforce for this post:

    Dan13071992 (11-24-2011)

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    Quote Originally Posted by tangoforce View Post
    Always, always, always use mysql_error() to find out what is wrong with your SQL.
    im using
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • Users who have thanked Fou-Lu for this post:

    Dan13071992 (11-24-2011)

  • #5
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    using what you said im now getting this error:

    PHP Code:
    Warningmysql_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
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,479
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Quote Originally Posted by Dan13071992 View Post
    im using
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    Along with what Fou has said, note that I said SQL not php
    I can't really think of anything to write here now...

  • #7
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    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
    http://360-tactics.co.uk/forum/index.php

    Crime-Wave

    please post your code wrapped in tags
    please post your PHP wrapped in tags

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,479
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Quote Originally Posted by Dan13071992 View Post
    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.
    I can't really think of anything to write here now...

  • #9
    New Coder
    Join Date
    Jul 2011
    Location
    Kediri - Indonesia
    Posts
    61
    Thanks
    2
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by Dan13071992 View Post
    using what you said im now getting this error:

    PHP Code:
    Warningmysql_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.

    lets we see your table structure.
    I am sorry my english is very bad. But I am very interest to discusse here :-)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •