Hi everyone,
First, let me explain I am a very knowledgable php developer. I'm not
someone trying to write their first script. I have been working on a
very large and complex problem for some time now when it suddenly
stopped working. I did not change anything in any configurations or
edit any code that would have affected how my database functionality
class would function. But, all of my connections started to bomb out.
Follows are the entire contents of a file simp.php (minus the line numbers):
1 <?
2
3 $db = mysql_connect("localhost", "web", "pw") || print "error
connecting ".mysql_error()." ".mysql_errno();
4 mysql_select_db("surveys");
5
6 $result = mysql_query("select * from attract") || print "error
querying ".mysql_error()." ".mysql_errno();
7
8 $i = 0;
9 while ($row = mysql_fetch_array(mysql_query("select * from
attract"))){ // && ($i++ < 5)){
10 echo $row[0]." ".$row[1]."<br>";
11 }
12 ?>
Please note that the user web@localhost identified by pw has permissions
to select from the table attract.
Here is what I have identified so far:
A - If I use $result in mysql_fetch_array() line 9, I get the error:
Warning: Supplied argument is not a valid MySQL result resource in
simp.php3 on line 9
But if I use the statement mysql_query("select * from attract")
in its
place, the loop (although infinite) will produce expected results, ie
print out the first and second columns of the first row of the table
infinitely. So basically, I would conclude the life of the variable
result is terminiating before I can use it. Why, I don't have a clue.
B - Being tired of an infinite loop in my investigation, I added line 8
and I placed the statement && ($i++ < 5) inside the while loop
condition. Now, only the <br> and spaces from line 10 will print, not
the actual values of the $row array. The output is <br> <br> <br> <br>
<br>, with no values from the table attract.
This is where I stand now, completely flabberghasted and nearly insane.
Can anyone shed any light on this before I have to commit to bringing
down the webserver while I reinstall php4. (oh, btw I am running
Apache/1.3.14 (Unix) PHP/4.0.4pl1 on Red Hat 6.2 (I hate redhat, but the
bossman says its better supported than slakware. bah.))
Thank you all for your help.
steve
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]