|
|
| Author |
Message |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| simon1221 |
This post is not being displayed .
|
 simon1221 World Chat Champion

Joined: 28 Jul 2004 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 10:25 - 23 Mar 2006 Post subject: |
 |
|
Here's your answer:
| Code: | $sqlquery = "SELECT * FROM $department WHERE manufacturer = $manufacturer";
$results = mysql_query($sqlquery)
or die("Could not execute query, please try again later"); |
Basically it's the difference between single and double quotes.
Using single quotes, the string is exactly what you type. Using double quotes, variables are resoved to their values.
So, if $variable = "banana";
Then 'This is a $variable' will be the string This is a $variable.
Whereas "This is a $variable" will be the string This is a banana.
 ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 12:45 - 23 Mar 2006 Post subject: |
 |
|
What are the commands on lines 65 and 84 then? ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
 Posted: 12:49 - 23 Mar 2006 Post subject: |
 |
|
Just to add, I have other pages running queries on this database which work fine.
Just can't see where this is failing
Could it be that the form isn't passing the values through I've checked every line of code, but from experience I know these problems are usually simple in the end!!!
Appreciating the help guys  ____________________ Past: Honda NSR125R >> Kawasaki ER-5a2 >> Kawasaki ZZR-600e1 >> Suzuki GSXR-750Y >> Honda VTR 1000 Firestorm
"Chickity China the Chinese Chicken..." |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 13:00 - 23 Mar 2006 Post subject: |
 |
|
You got MSN or something?
I don't have yahoo messenger. ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Kickstart |
This post is not being displayed .
|
 Kickstart The Oracle

Joined: 04 Feb 2002 Karma :     
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 13:34 - 23 Mar 2006 Post subject: Re: SQL help needed |
 |
|
You have problems with that massive echo you've got too.
Should be $row['image'] since that should be an int or a string in the square brackets. The text alone is neither. You need some more quotes!  ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 13:36 - 23 Mar 2006 Post subject: |
 |
|
Try this...
| Code: | <?php
$department=$_POST['department'];
$manufacturer=$_POST['manufacturer'];
$name=$_POST['name'];
if (!$manufacturer)
{
echo '<center><hr>You must enter search criteria<br/>'
.'Please go back and try again<hr></center>';
exit;
}
mysql_pconnect('localhost', 'root', '') or die("Unable to connect to database");
mysql_select_db('valentines');
$sqlquery = "SELECT * FROM $department WHERE manufacturer = $manufacturer";
$results = mysql_query($sqlquery)
or die("Could not execute query, please try again later");
while ($row = mysql_fetch_array($results)){
echo '<table width="100%" cellpadding="5" border="0">
<tr>
<td colspan=2 width=100% bgcolor=#990000><font color=#FFFFFF>'.$row['name'].'</font></td></tr>
<tr>
<td rowspan=4><a href='.$row['image'].'><img src='.$row['image'].' height="150" width="150" /></a></td>
<td>Description : '.$row['description'].'</td>
</tr>
<tr>
<td>Colours : '.$row['colours'].'</td>
</tr>
<tr>
<td>Sizes : '.$row['sizes'].'</td>
</tr>
<tr>
<td>Price : '.$row['price'].'</td>
</tr>
</table>';}
if(mysql_num_rows($results)<1){
echo '<center><hr>No products found!<br>Please try again<hr></center>';
}
//mysql_free_result($results);
?> |
____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 14:06 - 23 Mar 2006 Post subject: |
 |
|
Something is obviously different.
Have you tried my corrected version yet? ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Kickstart |
This post is not being displayed .
|
 Kickstart The Oracle

Joined: 04 Feb 2002 Karma :     
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
 Posted: 18:32 - 23 Mar 2006 Post subject: |
 |
|
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Kickstart |
This post is not being displayed .
|
 Kickstart The Oracle

Joined: 04 Feb 2002 Karma :     
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| AcIdBuRnZ |
This post is not being displayed .
|
 AcIdBuRnZ World Chat Champion

Joined: 28 Jul 2003 Karma :   
|
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| simon1221 |
This post is not being displayed .
|
 simon1221 World Chat Champion

Joined: 28 Jul 2004 Karma :   
|
 Posted: 20:55 - 23 Mar 2006 Post subject: |
 |
|
Shouldve used the mysql_error function but oh well you got there in the end. ____________________ DNA50 (sorry) ->> TZR125l >> GPZ500S |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
| Suzuki |
This post is not being displayed .
|
 Suzuki Roger

Joined: 03 May 2005 Karma :  
|
 Posted: 09:59 - 24 Mar 2006 Post subject: |
 |
|
If the names of columns are 'special name', such as "order" or "select" etc, then you need to surround the names in backticks to get the SQL to work.
Sorry, should have noticed that earlier.  ____________________ <Simple> no I'm shaven Jon
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map |
|
| Back to top |
|
You must be logged in to rate posts |
|
 |
Old Thread Alert!
The last post was made 20 years, 166 days ago. Instead of replying here, would creating a new thread be more useful? |
 |
|
|