I apologize...I just posted this to the database list but then realized it
may not be a database issue, so thought I'd better give it a shot over here.

Help!

I've been having a weird problem today (and maybe it's been there all along,
just haven't noticed...it's only been live a few days).  I have a web page
that allows users to query my database by either subject or alphabet (A-Z).
Today (and I think I noticed it once before but didn't pay much attention),
if you do a query, the first time it comes back with the results.  The
second time, clicking the same letter (or sometimes other letters), for
instance, it comes back with a "Database Not Selected" error.  Or, every
time in a row for a dozen times it comes back with a "Database Not Selected"
error.  Or, sometimes it comes back with the results just fine for twenty
times in a row. Or, ...

You get the idea.  It doesn't happen all the time, just sometimes, and in no
particular order.  Very strange because I'm not changing a dang thing.
Anyway, I've already tried rebooting the server, no change.  And, I've tried
accessing the web page from other machines, same problem.  Has anyone ever
run into this?

I'm running Red Hat 7.2, Apache 1.3.23, MySQL 3.23.49a, and PHP 4.2.1.

Here's the code in the web page with only some name changes (for security,
ya know):

<?php
function Query()
        {
                global $mydb, $recordset, $total_rows, $letter;
                $letter = $_GET['letter'];
                mysql_select_db($database_mydb, $mydb);
                $query = sprintf("SELECT name
                                        FROM tbl_mytable
                                        WHERE name LIKE %s
                                        ORDER BY name ASC",
                                        SQLStr($letter . "%", "text"));
                $recordset = mysql_query($query, $mydb) or die(mysql_error());
                $total_rows = mysql_num_rows($recordset);
        }
?>

And then the code in my include where I keep all the db connection stuff:

<?php
$hostname_mydb = "localhost";
$database_mydb = "mydb";
$username_mydb = "user";
$password_mydb = "xxxxxxxx";
$mydb= mysql_pconnect($hostname_mydb, $username_mydb, $password_mydb) or
die(mysql_error());
?>

Any help is appreciated!!  Thanks!

Jeff


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

Reply via email to