GregL83 Posted April 22, 2008 Share Posted April 22, 2008 Hello, I am having a weird problem with my webhost. Originally I was running PHP 4.4.7 and MySQL. I had my application actively running. I then made the move to switch to OOP and needed to upgrade to PHP 5. I called my webhost and told them that I need PHP 5. They went ahead and enabled it. They then informed me that I was recieving an error in my ctg-error log. I can't fully remember the error but its was involving session_path line 0 and some othe warnings that didn't seem to affect my application. They told me they would update a path in a system setting to fix the error. After these two changes where made I went back to a previously functional application page and recieved a new error. "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in webpath/htdocs/locater.php on line 95" I have simplified the code that recieves this error. It is as follows: <?php ... query = "SELECT col3, col4 FROM samp WHERE col1 = 'test1' ORDER BY col3"; $result = mysql_query($query); while(list($col3, $col4) = mysql_fetch_row($result)){ echo $col3; echo $col4; } ... ?> I can't figure out why this does not work..... Please help! Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 22, 2008 Share Posted April 22, 2008 <?php $query = "SELECT col3, col4 FROM samp WHERE col1 = 'test1' ORDER BY col3"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)){ $col3 = $row['col3']; $col4 = $row['col4']; } echo $col3; echo $col4; Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2008 Share Posted April 22, 2008 The error message means your mysql_query() failed. You need to add some error checking and error reporting to find out why - $result = mysql_query($query) or die("Query failed: " . mysql_error()); Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 I added that line to my query and nothing changed...still the same errors. I don't think this is a coding error. The problem began after my webhost messed around with server settings. Does anybody have any clue how to find the problem and solve it?? I have tested this method of getting variables from my MySQL database and get this error evertime. It is very frustrating because it is only a few lines of code and I have two books and many tutorials saying the code is fine... Please Help!!! Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 <?php $query = "SELECT col3, col4 FROM samp WHERE col1 = 'test1' ORDER BY col3"; $result = mysql_query($query) or die("Query 1 failed due to ".mysql_error()); while ($row = mysql_fetch_assoc($result) or die("Query failed due to ".mysql_error())){ $col3 = $row['col3']; $col4 = $row['col4']; } echo $col3; echo $col4; added error checking. if the query is failing, it will tell you. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 @jonsjava: The way he used list() was fine. He can change that back. Now. Check your MySQL connection. It must be bad, which isn't letting the query go through. Do me a favor. What's the variable that you have your mysql_connect() assigned to? Do this: if (is_resource($variable)) { echo "MySQL connection fine." } else { die ("FAILED. =["); } Use the right variable. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 Ok.....I think were on to something...which guru can solve this.... I get the error: " Query failed: Table 'user_access.uinp' doesn't exist " I think this has to do with the server settings. Its weird though because this table is accessed for other functions... Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 Don't simplify the code for us this time. Give us 5 lines above and below the error, and the line with the error, obviously. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 ok I ran the test and the mysql connection is fine... I don't know how much that will help, because it is identical to the simplified version of this code. Keep in mind that this application ran perfectly fine for a few months until my webhost made the changes indicated at the begining of this thread. And the mystery is still not solved....thanks for you efforts so far though... I greatly appreciate it see code below in next post Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 hmm that code came out crappy..let me make it easier to read <?php function stringsize($string){ $limit = 12; $str = $string; if (strlen($str) > $limit){ $str = substr($str, 0, $limit).'...'; } return $str; } $query = "SELECT nme, tp, r, vd, ovr, rr, enr, vr, ser, bnr FROM ".$_GET['st']." WHERE ct = '".$_GET['ct']."' ORDER BY nme"; $result = mysql_query($query) or die("Query failed: ".mysql_error()); while (list($name, $type, $rater, $vd, $overall, $ratio, $enter, $value, $service, $bnr) = mysql_fetch_row($result) or die("Query failed: ".mysql_error())){ echo "<tr><td><div class=\"ltr_scn\"><a href=\"scene.php?st=".$_GET['st']."&ct=".$_GET['ct']."&sc=$name\">$name</div></a></td><td><div class=\"ltr_scn\">$type</div></td><td><div class=\"ltr_scn\"><a href=\"\">"; $rater = stringsize($rater); echo "$rater</div></a></td><td class=\"ltr_scn\">"; if($vd == "y"){ echo "Yes"; } else{ echo "No"; } ?> the rest of my code simply echo's the variables... Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 I'll assume $_GET['st'] contains "uinp", right? Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 no, that is a 2 letter state identifier. in my example it would be " ma " for massachusetts. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 so, there is a table for each state? can you verify that the table you are trying to query exists? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 the query you could run is this: $tables = mysql_query("SHOW TABLES;"); print $tables; Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 the table exists still. it was working well before my account settings were changed by my webhost. also, other functions use these tables and work fine.... Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 No offense. I have no doubt that the tables your app uses exists, but can you verify that *that* table exists? The error is saying that it can't find it. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 I ran this function <?php $tables = mysql_query("SHOW TABLES FROM user_access;"); print_r($tables); ?> All that printed was: " Resource id #3 " Also, I have other functioning pages using these tables. I have verified using PHPMYADMIN that all the tables are still intact.... Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 I ran this function <?php $tables = mysql_query("SHOW TABLES FROM user_access;"); print_r($tables); ?> All that printed was: " Resource id #3 " Also, I have other functioning pages using these tables. I have verified using PHPMYADMIN that all the tables are still intact.... <?php $tbl_query = mysql_query("SHOW TABLES FROM user_access"); while ($tables = mysql_fetch_array($tbl_query)) { $table_result[] = $tables[0]; } print_r($tables); ?> That should do it. Not sure how MySQL returns SHOW TABLES in php. >_> Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 <?php $tables = mysql_query("SHOW TABLES;"); $row = mysql_fetch_array($tables); print_r($row); ?> I ran this code myself on one of my databases. It works. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 my results.... Array ( [0] => ak [Tables_in_user_access] => ak ) Array ( [0] => al [Tables_in_user_access] => al ) Array ( [0] => ar [Tables_in_user_access] => ar ) Array ( [0] => az [Tables_in_user_access] => az ) Array ( [0] => ca [Tables_in_user_access] => ca ) Array ( [0] => co [Tables_in_user_access] => co ) Array ( [0] => ct [Tables_in_user_access] => ct ) Array ( [0] => de [Tables_in_user_access] => de ) Array ( [0] => fl [Tables_in_user_access] => fl ) Array ( [0] => ga [Tables_in_user_access] => ga ) Array ( [0] => hi [Tables_in_user_access] => hi ) Array ( [0] => ia [Tables_in_user_access] => ia ) Array ( [0] => id [Tables_in_user_access] => id ) Array ( [0] => il [Tables_in_user_access] => il ) Array ( [0] => in [Tables_in_user_access] => in ) Array ( [0] => ks [Tables_in_user_access] => ks ) Array ( [0] => ky [Tables_in_user_access] => ky ) Array ( [0] => la [Tables_in_user_access] => la ) Array ( [0] => ma [Tables_in_user_access] => ma ) Array ( [0] => md [Tables_in_user_access] => md ) Array ( [0] => me [Tables_in_user_access] => me ) Array ( [0] => mi [Tables_in_user_access] => mi ) Array ( [0] => mn [Tables_in_user_access] => mn ) Array ( [0] => mo [Tables_in_user_access] => mo ) Array ( [0] => ms [Tables_in_user_access] => ms ) Array ( [0] => mt [Tables_in_user_access] => mt ) Array ( [0] => nc [Tables_in_user_access] => nc ) Array ( [0] => nd [Tables_in_user_access] => nd ) Array ( [0] => ne [Tables_in_user_access] => ne ) Array ( [0] => nh [Tables_in_user_access] => nh ) Array ( [0] => nj [Tables_in_user_access] => nj ) Array ( [0] => nm [Tables_in_user_access] => nm ) Array ( [0] => nv [Tables_in_user_access] => nv ) Array ( [0] => ny [Tables_in_user_access] => ny ) Array ( [0] => oh [Tables_in_user_access] => oh ) Array ( [0] => ok [Tables_in_user_access] => ok ) Array ( [0] => or [Tables_in_user_access] => or ) Array ( [0] => pa [Tables_in_user_access] => pa ) Array ( [0] => ri [Tables_in_user_access] => ri ) Array ( [0] => sc [Tables_in_user_access] => sc ) Array ( [0] => sd [Tables_in_user_access] => sd ) Array ( [0] => tn [Tables_in_user_access] => tn ) Array ( [0] => tx [Tables_in_user_access] => tx ) Array ( [0] => users [Tables_in_user_access] => users ) Array ( [0] => ut [Tables_in_user_access] => ut ) Array ( [0] => va [Tables_in_user_access] => va ) Array ( [0] => vt [Tables_in_user_access] => vt ) Array ( [0] => wa [Tables_in_user_access] => wa ) Array ( [0] => wi [Tables_in_user_access] => wi ) Array ( [0] => wv [Tables_in_user_access] => wv ) Array ( [0] => wy [Tables_in_user_access] => wy ) the $_GET['st'] variable is set to 'ma' and that should select from that table. this page was correctly function before my webhost went and f'd it up Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 24, 2008 Share Posted April 24, 2008 So where the hell did this come from: " Query failed: Table 'user_access.uinp' doesn't exist " What's uinp? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 cleaned up: Array ( [0] => ak [Tables_in_user_access] => ak ) Array ( [0] => al [Tables_in_user_access] => al ) Array ( [0] => ar [Tables_in_user_access] => ar ) Array ( [0] => az [Tables_in_user_access] => az ) Array ( [0] => ca [Tables_in_user_access] => ca ) Array ( [0] => co [Tables_in_user_access] => co ) Array ( [0] => ct [Tables_in_user_access] => ct ) Array ( [0] => de [Tables_in_user_access] => de ) Array ( [0] => fl [Tables_in_user_access] => fl ) Array ( [0] => ga [Tables_in_user_access] => ga ) Array ( [0] => hi [Tables_in_user_access] => hi ) Array ( [0] => ia [Tables_in_user_access] => ia ) Array ( [0] => id [Tables_in_user_access] => id ) Array ( [0] => il [Tables_in_user_access] => il ) Array ( [0] => in [Tables_in_user_access] => in ) Array ( [0] => ks [Tables_in_user_access] => ks ) Array ( [0] => ky [Tables_in_user_access] => ky ) Array ( [0] => la [Tables_in_user_access] => la ) Array ( [0] => ma [Tables_in_user_access] => ma ) Array ( [0] => md [Tables_in_user_access] => md ) Array ( [0] => me [Tables_in_user_access] => me ) Array ( [0] => mi [Tables_in_user_access] => mi ) Array ( [0] => mn [Tables_in_user_access] => mn ) Array ( [0] => mo [Tables_in_user_access] => mo ) Array ( [0] => ms [Tables_in_user_access] => ms ) Array ( [0] => mt [Tables_in_user_access] => mt ) Array ( [0] => nc [Tables_in_user_access] => nc ) Array ( [0] => nd [Tables_in_user_access] => nd ) Array ( [0] => ne [Tables_in_user_access] => ne ) Array ( [0] => nh [Tables_in_user_access] => nh ) Array ( [0] => nj [Tables_in_user_access] => nj ) Array ( [0] => nm [Tables_in_user_access] => nm ) Array ( [0] => nv [Tables_in_user_access] => nv ) Array ( [0] => ny [Tables_in_user_access] => ny ) Array ( [0] => oh [Tables_in_user_access] => oh ) Array ( [0] => ok [Tables_in_user_access] => ok ) Array ( [0] => or [Tables_in_user_access] => or ) Array ( [0] => pa [Tables_in_user_access] => pa ) Array ( [0] => ri [Tables_in_user_access] => ri ) Array ( [0] => sc [Tables_in_user_access] => sc ) Array ( [0] => sd [Tables_in_user_access] => sd ) Array ( [0] => tn [Tables_in_user_access] => tn ) Array ( [0] => tx [Tables_in_user_access] => tx ) Array ( [0] => users [Tables_in_user_access] => users ) Array ( [0] => ut [Tables_in_user_access] => ut ) Array ( [0] => va [Tables_in_user_access] => va ) Array ( [0] => vt [Tables_in_user_access] => vt ) Array ( [0] => wa [Tables_in_user_access] => wa ) Array ( [0] => wi [Tables_in_user_access] => wi ) Array ( [0] => wv [Tables_in_user_access] => wv ) Array ( [0] => wy [Tables_in_user_access] => wy ) the table you are querying does not appear to exist. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 It is table 'ma' and it exists according to all the other scripts and functions except this one. sorry for posting the results like that. I have no idea where .unip comes from. I think its gotta be a setting of mysql, php.ini, or my web server... I am stumped and enraged that my webhost continues to tell me it is a scripting error without properly reviewing the circumstances. Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 hmm.. the error does say table user_acess.unip and that is the database name... Quote Link to comment Share on other sites More sharing options...
GregL83 Posted April 24, 2008 Author Share Posted April 24, 2008 anybody else have any ideas? I might just have to replicate this error in a simple script and tell my webhost to look at it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.