Thread: sql query
View Single Post
Old is offline
Member is on a distinguished road
Posts: 30
Join Date: Feb 2009
Location: DesMoines IA
Default sql query - 04-30-2012, 12:49 AM

I'm getting an error of could not execute the query. not sure what im doing wrong on this query. i'm just messing around with search through a database ofa drink recipe site im building. I wanna use a search option on this website.

PHP Code:
$user ="a7246488_serg91";
$password "xxxx";
$database ="a7246488_drinks";
$connection mysql_connect($host$user$password) or die ("couldn't connect to server");
$db mysql_select_db($database$connection) or die("couldn't select database.");
$name "drink"//user types in the name of drink
$query ="select NAME, INGREDIENTS, INSTRUCTIONS, CATEGORY from a1(1) where NAME = '%$name'";
$result mysql_query($query) or die ("Couldn't execute the query.");
$row mysql_num_rows($result);

//display the result of the table
$row mysql_fetch_array($result);
//this is where I think is where im going wrong
'<br>Ingredients: '.$row['Ingredients'];
'<br>instructions: '.$row['Instructions'];
'<br>category: '.$row['category'];
'<br>Image: '.$row['image'];
HTML Code:
<FORM action="search.php" method="post">
Search: <input type="text" name="term" /><br />
<input type="submit" name="submit" value="submit" />

Last edited by; 04-30-2012 at 01:22 AM. Reason: pw
Reply With Quote