Hi All,

I am trying to echo the held text in the "Title" field where the id has a fixed value of 1, but i am getting the following error:

supplied argument is not a valid MySQL result resource in C:\wamp\www\index.php on line 46

your help would be greatly appreciated.

the php code that i am using is:

<?php 
$sql_query = "SELECT 'id', 'Title' FROM 'indexinfo' WHERE 'id' = '1'"; 

//store the queried cell in the variable 
//named $result 
$result = mysql_query($sql_query);  

//display the queried cell 

$row = mysql_fetch_array($result);  // line 46
echo ($row['Title']);

 ?>

Recommended Answers

All 4 Replies

Romove the single quotes with table name(i.e. for indexinfo) and give the tild operator like this:`indexinfo`.I think you will get the result.And other this is its not necessary giving braces for echo statements.
It can be like this:echo $row;

Hi thanks for the response.

I amended the code to the following, but I still recieve the same error.

<?php 
$sql_query = "SELECT `id`, `Title` FROM `indexinfo` WHERE `id` = 1"; 

//store the queried cell in the variable 
//named $result 
$result = mysql_query($sql_query);  

//display the queried cell 

$row = mysql_fetch_array($result); 
echo $row['Title'];

 ?>

try this $sql_query = "SELECT id, Title FROM `indexinfo` WHERE id = 1";

Hi Thanks so much for your help,

Your advice was perfect, along with me discovering i was referring to the wrong database :-(

Very much appreciated

regards

Paul

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.