> -----Original Message-----
> From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
> Sent: 24 April 2002 04:46
> 
> Would you please direct your attention to this URL
> 
> http://testphp.netfirms.com/code1.html
> 
> Look at the bottom where the big orange commented syntax is 
> and explain what
> is going on there?

========================================
$query = "SELECT name FROM {$config["prefix"]}_users WHERE uid={$session["uid"]}";

$ret = mysql_query($query);

 

// this is line 14
while($row = mysql_fetch_array($ret))
.
.
.
// this is the problem area. It is giving me this sql warning Warning: Supplied 
argument is not a valid MySQL result resource in /home/public_html/sortitems.php on 
line 14 look at top for line 14 why is it

// looking at line 14 I am not asking for any of that information?
========================================

No idea why the error message is so far down the page, but it is certainly referring 
to line 14 -- it is telling you that the $ret you are supplying to mysql_fetch_array 
is invalid.  Why?  Because the mysql_query failed, and so $ret was not assigned valid 
result resource.  This is why you should ALWAYS check the return value of a 
mysql_query call before trying to fetch its results.

Now, why is the query failing?  Well, let's take a look at this line:

    $query = "SELECT name FROM {$config["prefix"]}_users WHERE uid={$session["uid"]}";

The stuff to the right of the "=" consists of:

    (1) the string "SELECT name FROM {$config["
    (2) the constant named prefix (which, I guess, doesn't exist)
    (3) the string "]}_users WHERE uid={$session["
    (4) the constant named uid (ditto!)
    (5) the string "]}"

with NO concatenation operators in between.

This line ought to generate multiple warnings and notices -- you must have 
error_reporting set to suppress all these useful messages, so I suggest you change it 
to something more useful forthwith (such as E_ALL, or at least E_ALL ^ E_NOTICE).

So, the final solution to your problem would be either of the following:

    $query = "SELECT name FROM {$config[\"prefix\"]}_users WHERE 
uid={$session[\"uid\"]}";

    $query = "SELECT name FROM {$config['prefix']}_users WHERE uid={$session['uid']}";

Hope this helps.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to