469,646 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Result Set Problem - Really Weird.....

I am new to programming in PHP however, this should be a pretty
straight forward answer. I have three queries that I am pulling for a
content form page.

1) The Author List
2) The Content Page (pulls the PK, Title and the Description of the
content.
3) The Category List

When I attempt to pull the data the only result set I get back is from
the Item #1 query above. Now, I made sure that there is data in the
tables, but I still get no data back for the other two queries(????)

Is there something that I missing when connecting to PHP/MYSQL? Do I
need to take some additional steps??

Any help would be greatly appreciated. I've been struggling with this
problem for several hours now scratching my head why this is.

:-)

// here is the PHP Code I am using

<?php
$db = mysql_connect("$DB_SERVER", "$DB_SERVER_USERNAME",
"$DB_SERVER_PASSWORD");
mysql_select_db("$DB_DATABASE",$db);
//result set 1 - get members
$result_M=mysql_query("SELECT * FROM tblMembers",$db);
$myrow_M=mysql_fetch_assoc($result_M);
//result set 2 - get content ID
$result_C=mysql_query("SELECT * FROM tblContent WHERE
contentID=1",$db);
$myrow_C=mysql_query($result_C);
//result set 3 - get categories
$result_Cat=mysql_query("SELECT * FROM tblCat",$db);
$myrow_Cat=mysql_query($result_Cat);
//result set 1 - output
$memID =$myrow_M['memberID'];
$fname =$myrow_M['fname'];
$lname =$myrow_M['lname'];
//result set 2 - output
$contentID =$myrow_C['contentID'];
$Title =$myrow_C['Title'];
$e1m1 =$myrow_C['Descr'];
//result set 3 - output
$CatID = $myrow_Cat['CatID'];
$CatName = $myrow_Cat['CatName'];
echo ($memID);
echo ($fname);
echo ($lname);
echo ($contentID);
echo ($Title);
echo ($e1m1);
echo ($CatID);
echo ($CatName);

return false;

?>

Feb 20 '06 #1
3 1199
> When I attempt to pull the data the only result set I get back is from
the Item #1 query above. Now, I made sure that there is data in the
tables, but I still get no data back for the other two queries(????)
<snip> // here is the PHP Code I am using

<snip: lots of PHP code without error checking>

I suggest you ask the mysql_errno() mysql_error() functions first.

Best regards
Feb 20 '06 #2
coder wrote:
I am new to programming in PHP however, this should be a pretty
straight forward answer. I have three queries that I am pulling for a
content form page.

1) The Author List
2) The Content Page (pulls the PK, Title and the Description of the
content.
3) The Category List

When I attempt to pull the data the only result set I get back is from
the Item #1 query above. Now, I made sure that there is data in the
tables, but I still get no data back for the other two queries(????)

Is there something that I missing when connecting to PHP/MYSQL? Do I
need to take some additional steps??

Any help would be greatly appreciated. I've been struggling with this
problem for several hours now scratching my head why this is.

:-)

// here is the PHP Code I am using

<?php
$db = mysql_connect("$DB_SERVER", "$DB_SERVER_USERNAME",
"$DB_SERVER_PASSWORD");
mysql_select_db("$DB_DATABASE",$db);
//result set 1 - get members
$result_M=mysql_query("SELECT * FROM tblMembers",$db);
$myrow_M=mysql_fetch_assoc($result_M);
//result set 2 - get content ID
$result_C=mysql_query("SELECT * FROM tblContent WHERE
contentID=1",$db);
$myrow_C=mysql_query($result_C);
//result set 3 - get categories
$result_Cat=mysql_query("SELECT * FROM tblCat",$db);
$myrow_Cat=mysql_query($result_Cat);
//result set 1 - output
$memID =$myrow_M['memberID'];
$fname =$myrow_M['fname'];
$lname =$myrow_M['lname'];
//result set 2 - output
$contentID =$myrow_C['contentID'];
$Title =$myrow_C['Title'];
$e1m1 =$myrow_C['Descr'];
//result set 3 - output
$CatID = $myrow_Cat['CatID'];
$CatName = $myrow_Cat['CatName'];
echo ($memID);
echo ($fname);
echo ($lname);
echo ($contentID);
echo ($Title);
echo ($e1m1);
echo ($CatID);
echo ($CatName);

return false;

?>


Check the results from your queries. If FALSE is returned, you have an
error. Call mysql_errno() and mysql_error() to find out what it is, i.e.

$result_C=mysql_query("SELECT * FROM tblContent WHERE contentID=1",$db);
if ($result_C) (
$myrow_C=mysql_query($result_C);
}
else {
echo {"MySQL Error detected: " . mysql_error() . "<br>\n");
}

ALWAYS check the results of ANY call to MySQL!
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 20 '06 #3
Thanks you both for your reply and assistance - this is exactly what I
was missing. :-)

Feb 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Gonçalo Rodrigues | last post: by
2 posts views Thread by ai lian | last post: by
3 posts views Thread by Protoman | last post: by
47 posts views Thread by fb | last post: by
12 posts views Thread by Mick_fae_Glesga | last post: by
reply views Thread by P Pulkkinen | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.