Jump to content

[SOLVED] Small SELECT problem


forumnz

Recommended Posts

<?php
$con = mysql_connect("localhost","aaa","aaa");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
$id = "127";

$query  = "SELECT title FROM 'help' WHERE 'id'=$id";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo $row['title'];
}


mysql_close($con);
?>

 

Gets me:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /httpdocs/clients/page.php on line 59

 

How do I fix it?

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/80814-solved-small-select-problem/
Share on other sites

try this:

 

<?php
$con = mysql_connect("localhost","aaa","aaa");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
$id="127";

$query  = "SELECT title FROM help WHERE id='$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo $row['title'];
}


mysql_close($con);
?>

That didn't work phpQuestioner. Thanks though.

 

This is the error I got:

Error in query: SELECT title FROM 'help' WHERE 'id'=127. 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 ''help' WHERE 'id'=127' at line 1

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.