PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am new to this forum and I am having some major problems with some code. I wrote some php pages and they work fine on my windows machine but when I upload them to my host which is Debian Linux. The following function does not work fetch_assoc();
I am posting the code below
How can i check the error log? the hosting company i think will not allow me to do this.
I dont get no errors all it says page not found, if i take out the fetch_assoc it will work for example if i try to delete from the database. I am so stuck (:-<).
I have also disabled windows friendly error messages so i could see some errors but it does not work
if i try the older style coding then it does return results but i have completed my whole project in php5 object orientated style
Thankyou for helping me, the code below is the exact code im using in my project. I put in a counter to see if it returns a resultset and my counter counts 15 times. This is the number of rows in my table, so i presume it is getting a resultset. Can their be any sort of php.ini file configuration the administering host might need to do?
Is fetch_assoc part of php4 aswell? Can it be fetch_assoc library is not present?
<?php
// Connect to database using the new and improved mysqli
$dbLink = new mysqli('localhost', 'user', 'password', 'database');
if(!$dbLink) {echo 'connection error';}
//query db system
$query ="select * from tbl_debug";
$result = $dbLink->query($query);
//test to see if results were returned
$num_results=$result->num_rows;
$count=1;
if ($num_results > 0) {
for($i=0; $i <$num_results; $i++) {
//$row=$result->fetch_assoc();
//echo 'Title row: '.$row['debug_Title'];
echo $count;
$count++;
}
}
echo 'test script ';
// garbage collection
if ($result <> null) {
$result->free();
$dbLink->close();
}
?>
I did a code dump as you suggested and i get the following output. I cant understand what it is telling me. but it seems to be empty, am i correct? why would this be.