Jump to content
Larry Ullman's Book Forums

Php Myadmin And Php Script Return Different Results


Recommended Posts

Here is a script that I typed into php MyAdmin:

 

SELECT

M.media_name FROM media as M

INNER JOIN member_media as J on J.mediaID = M.mediaID

WHERE J.maaMemberId = 209

 

The number of rows it returns is 3

 

Here is the php version:

 

$q = "SELECT

M.media_name FROM media as M

INNER JOIN member_media as J on J.mediaID = M.mediaID

WHERE J.maaMemberId = 209";

 

$r = @mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));

$row = mysqli_fetch_array ($r, MYSQLI_NUM);

echo $row[0];

echo $row[1];

echo $row[2];

exit();

 

The only result is $row[0] which is a correct result (matches first row in first example)

The other 2 rows give "Undefined offset"

Link to comment
Share on other sites

I guess I've been working with ASSOC arrays too long. It seems that the entire results of the SELECT is given within a single array $row[0]. I was thinking that the 3 results were equal to 3 separate rows so that it would be stored in $row[0], $row[1],$row[2]. But it's not, it's all a single row of results.. right?

 

Hmmm, okay, you have my permission to change my "Advanced Member" status to "Advanced Dementia".

Link to comment
Share on other sites

 Share

×
×
  • Create New...