Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-12-2010, 08:04 AM SQL/PHP error
Novice Talker

Posts: 6
Name: David Reid
Trades: 0
Hi All, I am relativly new to all this and have been wrestling with this problem for the last few hours... I decided it was time to ask for a little help, so HEEEEELP!!

When I try to run this code;

<?php
$category_txt = $_GET['category'];
$_SESSION['category'] = $category_txt;
if ($category_txt=="bar") {$category_disp="Bars";}
if ($category_txt=="hotel") {$category_disp="Hotels";}
if ($category_txt=="restaurant") {$category_disp="Restaurants";}
if ($category_txt=="tours") {$category_disp="Tours";}
$category_yes = "1";
?>

I get an error that says:
"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 '=''' at line 1"

Any help would be greatly appreciated

Chheers,

Dave
chopper3226 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-12-2010, 08:09 AM Re: SQL/PHP error
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
There isn't a SQL query in the code you posted.

The error must be coming from somewhere else.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-12-2010, 08:10 AM Re: SQL/PHP error
Skilled Talker

Posts: 54
Trades: 0
hi david can you please post the sql query since the error is with the query so that you can be helped.
kani alavi is offline
Reply With Quote
View Public Profile
 
Old 07-12-2010, 08:12 AM Re: SQL/PHP error
Novice Talker

Posts: 6
Name: David Reid
Trades: 0
WOW!! Thanks for the awesome response time....could it be here?

<?php
$result = mysql_query("SELECT * FROM advertiser WHERE $category_txt='$category_yes'") or die(mysql_error());
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$name_txt = $row['name'];
$image_txt=$row['image'];
$description_txt=$row['description'];

I ran this in my database and didn't get an error
chopper3226 is offline
Reply With Quote
View Public Profile
 
Old 07-12-2010, 08:20 AM Re: SQL/PHP error
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Are $category_txt and $category_yes being set?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-12-2010, 08:22 AM Re: SQL/PHP error
Skilled Talker

Posts: 54
Trades: 0
cross check the field names of your advertiser table whether you have a field named '$category_txt' i mean with the ampersand preceding the name. the ampersand might be causing the error.
kani alavi is offline
Reply With Quote
View Public Profile
 
Old 07-12-2010, 08:27 AM Re: SQL/PHP error
Novice Talker

Posts: 7
Location: USA
Trades: 0
also check that $category_txt is not a typo. maybe you meant to type category_txt ??? Meaning that you did not want to use a PHP variable there but instead use a db field ??
__________________

Please login or register to view this content. Registration is FREE

Get various info about a website!
Who is hosting it, Google PR, Whois, Backlinks...
checkwebsite is offline
Reply With Quote
View Public Profile Visit checkwebsite's homepage!
 
Old 07-12-2010, 08:36 AM Re: SQL/PHP error
Novice Talker

Posts: 6
Name: David Reid
Trades: 0
Hi All,
Thanks for your help... all I had to do was add ?category="whatever" at the end of the URL and it works

Thanks again
chopper3226 is offline
Reply With Quote
View Public Profile
 
Old 07-13-2010, 04:15 AM Re: SQL/PHP error
Experienced Talker

Posts: 41
Trades: 0
<?php
$category_txt = $_GET['category'];
$_SESSION['category'] = $category_txt;

if ($category_txt == "bar")
{
$category_disp="Bars";
}

if ($category_txt=="hotel")
{
$category_disp="Hotels";
}

if ($category_txt=="restaurant")
{
$category_disp="Restaurants";
}

if ($category_txt=="tours")
{
$category_disp="Tours";
}
$category_yes = "1";
?>

According to me till now in that script, there is no error I face,then please mention here full code script,then , I'll definitely solve them.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
.
sandeep Kumar is offline
Reply With Quote
View Public Profile Visit sandeep Kumar's homepage!
 
Reply     « Reply to SQL/PHP error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27883 seconds with 12 queries