--- sheryl <[EMAIL PROTECTED]> wrote:
> I have 2 pages, index.php and menu.php
>
> menu.php is included via require_once in index.php, just after the
> beginning of the body tag.
>
> My select in index.php is returning Resource id #13, but no rows. If
> I echo the query and then paste that into phpMyAdmin, it returns one
> row (as it should).
>
> If I remove the call to menu.php, the query returns 1 row.
>
> Menu.php is working correctly.
>
> When I click one of the links and reload index.php, it echos this:
>
> SELECT * FROM pages WHERE id=2 LIMIT 1 Resource id #13 0
>
> What am I doing wrong?!
>
>
>
> Here's the related code from index.php:
>
>
> require_once("menu.php");
>
> if($page_id){
> }else{
> $db="my_db_goes_here";
> $page_id=1;
> } //endif
>
> $connection=my_connect($host,$username,$password,$db);
>
> $query="SELECT * FROM pages WHERE id=$page_id LIMIT 1";
> $sql=mysql_query($query) or die("Unable to query: ".$query);
>
> echo $query." ".$sql," ".mysql_num_rows($sql);
Is my_connect() a custom function? Did you mean mysql_connect() ?
In mysql_connect() (http://php.net/mysql_connect) the fourth argument is a
boolean value to manage
connections to the database server, not the database name. You should use
mysql_select_db($db)
(http://php.net/mysql_select_db) to identify the database (which you do in
phpMyAdmin or from the
commandline).
> Here's most of menu.php, minus some superfluous html:
>
> foreach($db_array as $db){
>
> $connection=my_connect($host,$username,$password,$db);
Same issue here.
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Spring Semester January-June 2006. Two new class topics.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/