ramsay Posted April 13, 2007 Share Posted April 13, 2007 hello im getting the error Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in... i was using the msqli extension but getting a fatal error of Fatal error: Call to a member function fetch_row() on a non-object in so i changed back the the msql extension and have the current problem. do i need to download the latest connector files? any help would be great, cheers ramsay Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 13, 2007 Share Posted April 13, 2007 wanna show some code? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 13, 2007 Share Posted April 13, 2007 sometimes you get this erro when you are using mysql instead of ,myqli, different versions of mysql.... whic version of mysql are you running, if its 4.1.14 of higher ( from memory) it needs to be mysqli, other than that..... try mysql_fetch_array it gets both numbered arrays: eg $array[1] & $array['text_index']; gdlk Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 13, 2007 Author Share Posted April 13, 2007 if(! @include('includes/connection.inc.php')) //including connection { echo 'sorry database unavailable'; exit; } define('COLS',2); //defining number of columns define('SHOWMAX',6); //maximum number or records per page $conn = dbConnect('query'); //create connection $getTotal = 'SELECT COUNT (*) FROM images'; //prepare sql to get total records $total = mysql_query($getTotal); //submit query and store as totalpix $row = mysql_fetch_row($total); $totalPix = $row[0]; if(isset($_GET['curPage'])) { $curPage = $_GET['curPage']; } else { $curPage = 0; } $startRow = $curPage * SHOWMAX; //calculate start of subset $sql = "SELECT * FROM images LIMIT $startRow,".SHOWMAX; //prepare sql to recieve image details $result = mysql_query($sql) or die(mysqli_error()); //submit query $row = mysql_fetch_assoc($result); ------------------------------------------------------------------------------------------------- and in my body... <?php echo $startRow+1; if ($startRow+1 < $totalPix) { echo ' to '; if ($startRow+SHOWMAX < $totalPix) { echo $startRow+SHOWMAX; } else { echo $totalPix; } } echo " of $totalPix"; ?></p> --------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 13, 2007 Author Share Posted April 13, 2007 well i was using mysqli but was recieving a fatal error. i read somewhere that it could be a bug in msqli so i reverted back to msql and am now getting this problem. cheers Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 13, 2007 Author Share Posted April 13, 2007 im running MySQL server 5 by the way. thanks again. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 13, 2007 Share Posted April 13, 2007 you HAVE to use mysqli if its certain versions, its just syntax...... its like trying to use "random_number(between 10 and 20)" instead of "rand(10, 20)" my mysqli is fine, its works perfectly...... ill help if you need buut i think youll be needing to use that Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 13, 2007 Author Share Posted April 13, 2007 ok well il go revert back to mysqli and post when iv done it. what about using PDO, is that reccommended? thanx Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 14, 2007 Author Share Posted April 14, 2007 i changed back to mysqli, all my other pages are working fine but im stil getting the error i was before. Fatal error: Call to a member function fetch_row() on a non-object in D:\Project-WebSite\public_html\Project\gallery.php on line 15 from this code if(! @include('includes/connection.inc.php')) //including connection { echo 'sorry database unavailable'; exit; } define('COLS',2); //defining number of columns define('SHOWMAX',6); //maximum number or records per page $conn = dbConnect('query'); //create connection $getTotal = 'SELECT COUNT (*) FROM images'; //prepare sql to get total records $total = $conn->query($getTotal); //submit query and store as totalpix $row = $total->fetch_row(); $totalPix = $row[0]; $curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 0; //set the current page $conn = dbConnect('query'); //create connection to mysql $startRow = $curPage * SHOWMAX; //calculate start of subset $sql = "SELECT * FROM images LIMIT $startRow,".SHOWMAX; //prepare sql to recieve image details $result = $conn->query($sql) or die(mysqli_error()); //submit query $row = $result->fetch_assoc(); if (isset($_GET['image'])) { $mainImage = $_GET['image']; } else { $mainImage = $row['filename']; } $imageSize = getimagesize('images/'.$mainImage); // get the dimensions of the main image -------------------------------------------------------------- help would be great, cheers. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 14, 2007 Share Posted April 14, 2007 You are using fetch_row and fetch_assoc...it seems as though fetch_row is not a function. Try this instead: $total = $conn->query($getTotal); //submit query and store as totalpix $row = $total->fetch_assoc(); And [ code ] tags are your friend, not the enemy. Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 14, 2007 Author Share Posted April 14, 2007 reied the fetch_assoc() and stil go the same error Fatal error: Call to a member function fetch_assoc() on a non-object in any more ideas? cheers Quote Link to comment Share on other sites More sharing options...
per1os Posted April 14, 2007 Share Posted April 14, 2007 $conn = dbConnect('query'); Where is the code for dbConnect? Quote Link to comment Share on other sites More sharing options...
ramsay Posted April 14, 2007 Author Share Posted April 14, 2007 <?php function dbConnect($type) { if ($type == 'query') { $user = 'lcquery'; $pwd = '********'; } elseif ($type == 'admin') { $user = 'lcadmin'; $pwd = '*******'; } else { exit('Unrecognized connection type'); } $conn = new mysqli('localhost', $user, $pwd, 'lordconyersfc') or die('cannot open database'); return $conn; } ?> ---------------------------------------------------------------------------------------- the data base is connecting fine though as i have other parts of the database on other parts of ths site which work fine, the gallery also worked fine up untlil now too 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.