"Resource id #11"

Hello, so I’m using 000webhost for this site that I’m building for a friend. I’m making a banner, that is updatable and stuff. Whenever I echo it on the header.php, to display to people. It just says, “Resource id #11”. Can you please help me?

[php]<?php
require (‘connect.php’);

$message = $_POST[‘message’];

$sql = mysql_query(“UPDATE banner SET banner=’$message’”);

$sql3 = mysql_query("SELECT rank FROM users");
if($sql3[‘rank’] == 2) {
echo ’ $form = <<<EOT

Message:

EOT’;

$sql2 = mysql_query("SELECT * FROM `banner` WHERE `banner` = $message");

echo '$form';

echo ’ $message ';
}else{
echo ‘You are not an Admin!’;
}
?>[/php]
My header.php
[php]

JoshTestSite <?php error_reporting(E_ALL ^ E_NOTICE); session_start(); $user = $_SESSION['user']; $id = $_SESSION['id']; $message = mysql_query("SELECT `banner` FROM `banner`"); require('connect.php');

if ($user && $id){
echo "














Home

$message

Help

Staff

Forum

Plugins

Logout

";
}else{
echo ’












Home

Members

Help

Staff

Forum

Plugins

';
}

echo ‘

’;
?>
[/php]

mysql_query does not fetch the results. In order to fetch them, you need to use the resource it returns and pass it as an argument of mysql_fetch_assoc() (or equivalent function).

[php]<?
$myrequest = mysql_query(“SELECT 1 AS foo”);
$myresult = mysql_fetch_assoc($myrequest);
var_dump($myresult);[/php]

Since you are new to DBs, I strongly recommend learning PDO right off the bat instead of mysql_. mysql_ is deprecated and will disappear in PHP 5.5 (in one version’s time), and PDO is more secure.

now I get something that says, “bool(false)”

My request was a placeholder. Replace it with yours.

bool(false) means it didn’t find a single result.

is it maybe what’s in my phpmyadmin?
I haven’t messed around with my site for a few months. I forgot what I was working on.

Anyways, I did replace it with what you put.

Sponsor our Newsletter | Privacy Policy | Terms of Service