View Single Post
Old 06-04-2004, 08:58 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
well the problem may be that you don't have a single quote around the value you are sending to your query.

i refined your top php script a bit so you don't have to us multiple queries. check out the comments.

caution though, i don't know your data schema, and if you are even using 2 tables, i just assumed it:

PHP Code:
<?
$lnk 
mysql_connect('mysqladdress''login''password') or die (mysql_error());

// this must be the Database Name, NOT the tablename.
mysql_select_db('dbname',$lnk);

// try using single quotes around the value you are querying
// also, just use a join instead of making 2 queries
$sql "SELECT table1.title AS title,table2.entry AS entry FROM table1,table2 
        WHERE table1.id = '"
.$entryid."' AND table1.id=table1.id";
        
// when i'm having sql problems, i usually echo my sql statement,
// then i can copy and paste into phpmyadmin ( or whatever db admin you use )
// to see the exact error mysql generates.
echo $sql "<br><br>\n";

// you really don't need the second argument of mysql_query if you only have 1 db open
$result mysql_query($query_title) or die(mysql_error());

// now run a loop in case you retrieve multiple results:
while($row mysql_fetch_array($result)){
  
$title stripslashes($row['title']);
  
$entry stripslashes($row['entry']);

  
// print result if you want
  
echo $title " : " $entry "<br>\n";
}
?>
let me know if this works.
__________________
Mike
sde is offline   Reply With Quote