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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nesd help with php and coding

    I am very new to php and codding i had some help creating this but now i need more help

    I am getting this error

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/pealight/domains/pealight.lt/public_html/justinas/duomenys.php on line 119

    Can someone please help

    Here are my php files and sql file http://www.mediafire.com/?91a6loysdevxv5l

    Thankyou

  • #2
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No help needed anymore it was a database problem

  • #3
    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
    The issue is still actually a PHP one; the code needs to be written to deal with the failures of the communication or incorrectly structured requests.
    When you write it, you need to check that the connection was established correctly, and make sure the queries are successful when you do execute them. How you write it depends on the control you want. You can be as lazy as using or die(); syntax on the resource commands like mysql_query, so if it returns false than it terminates the script. I would put a little more work into it though:
    PHP Code:
    if ($qry mysql_query('...'))
    {
        
    // this is fine.
    }
    else
    {
        
    // this failed, likely due to syntactical issues in the SQL request.  Do what you need to do.

    If the query fails and you attempt to pass it into a fetch, the error will always be the same: expecting a resource and was given a boolean. The boolean is false since it failed to execute properly (which really should be null, not boolean, but at least the mysqli fixes that).

    So in essence, you simply want to make sure that anytime you operate on any external entity such as a file or database to check that the resources are valid before you attempt to do anything with them. Like with a file, you would make sure it is actually opened prior to attempting to read from it, or you would see a similar error where the filehandle isn't a valid resource. Same goes with the db, you want to ensure that the query you have run was successful prior to attempting to read it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks


  •  

    Posting Permissions

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