Jump to content

Warning: mysql_fetch_row


ramsay

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

---------------------------------------------------------------

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.