Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-23-2013, 02:42 PM   PM User | #1
justinas91
New to the CF scene

 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
justinas91 is an unknown quantity at this point
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
justinas91 is offline   Reply With Quote
Old 01-23-2013, 04:40 PM   PM User | #2
justinas91
New to the CF scene

 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
justinas91 is an unknown quantity at this point
No help needed anymore it was a database problem
justinas91 is offline   Reply With Quote
Old 01-23-2013, 05:00 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 01-24-2013, 04:06 PM   PM User | #4
justinas91
New to the CF scene

 
Join Date: Jan 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
justinas91 is an unknown quantity at this point
thanks
justinas91 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:07 PM.


Advertisement
Log in to turn off these ads.