On 3/16/2006, "sheryl" <[EMAIL PROTECTED]> wrote:
>
>
>
>
>I searched the messages but didn't see anything related to this.. I
>could really use some help. I've been coding php and mysql for years,
>but this is the first time I've messed with different databases in one
>place and the solution is escaping me.
>
>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);
>
>
>
>Here's most of menu.php, minus some superfluous html:
>
>foreach($db_array as $db){
>
>$connection=my_connect($host,$username,$password,$db);
>
>$query="select * from pages order by filename";
>$sql=mysql_query($query) or die("Unable to query: ".$query);
>
>while($row=mysql_fetch_array($sql)){
> $link=stripslashes($row['linkname']);
>?>
> <a href="index.php?db=<?=$db?>&page_id=<?=$row['id']?>">
> <?=$link?>
> </a>
><?php
>} //endwhile
>
>mysql_close($connection);
>
>} //endforeach
>
>
Sheryl - in your index.php file, just before you establish the
connection, double-check that $db contains what you expect.
There may be a scoping issue between the db parameter you're passing in
post vars, and the foreach($dbarray as $db) statement in menu.php.
At least, that's where I'd start.
Mike
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/