Jump to content

Error Calling array


thebusiness

Recommended Posts

I am getting this error

 

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /path/to/rockslider.inc.php on line 6

 

With this code

 

 

<?php

$sql = mysql_query("SELECT * FROM ava_slider ORDER BY id desc LIMIT 5");


while($row = mysql_fetch_array($sql)) {

$rock_slider['title'] = $row['name'];
$rock_slider['url'] = $row['url'];
$rock_slider['description'] = $row['description'];
$rock_slider['image'] = $row['image'];

include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php';
}
?>

 

 

Any help

Link to comment
Share on other sites

Pretty much just what the error says.  See link in my signature about mysql problems.

 

Okay

 

this is the error

 

Could not successfully run query (Resource id #38) from DB: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #38' at line 1

Link to comment
Share on other sites

Seems to be unhappy with your query, although I don't understand that error message.  What is the exact code you have right now?

 

<?php
$sql = mysql_query("SELECT * FROM ava_games ORDER BY id desc LIMIT 5");
$row = mysql_query($sql);
if (!$row) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}

while($row = mysql_fetch_array($sql)) {

$rock_slider['title'] = $row['name'];
$rock_slider['url'] = $row['url'];
$rock_slider['description'] = $row['description'];
$rock_slider['image'] = $row['image'];

include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php';
}
?>

Link to comment
Share on other sites

You are calling a query on a query.  Change $sql to this:

$sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5";

 

Now

 

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hameda/public_html/gametako/includes/rock/rockslider.inc.php on line 13

Link to comment
Share on other sites

You are calling a query on a query.  Change $sql to this:

$sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5";

 

Now

 

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hameda/public_html/gametako/includes/rock/rockslider.inc.php on line 13

 

 

 

this is current

 

<?php
$sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5";
$row = mysql_query($sql);
if (!$row) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}

while($row = mysql_fetch_array($sql)) {

$rock_slider['title'] = $row['name'];
$rock_slider['url'] = $row['url'];
$rock_slider['description'] = $row['description'];
$rock_slider['image'] = $row['image'];

include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php';
}

?>

Link to comment
Share on other sites

This worked

 

<?php
$sql = "SELECT * FROM ava_games ORDER BY id desc LIMIT 5";
$result = mysql_query($sql);


while($row = mysql_fetch_array($result)){

$rock_slider['title'] = $row['name'];
$rock_slider['url'] = $row['url'];
$rock_slider['description'] = $row['description'];
$rock_slider['image'] = $row['image'];

include $_SERVER['DOCUMENT_ROOT'] . '/includes/rock/rockslider.php';
}
?>

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.