brettpower Posted December 28, 2006 Share Posted December 28, 2006 I am attempting to pull a URL variable and drop it into a WHERE clause, however, I am having no luck! The URL variable does seem to pass to the mySQL query, but the query fails. From my research, it appears to be a syntax issue.Here is what I have:[code]$cid = $_GET['campaign'];mysql_select_db($database_Offer, $Offer);$query_Offer = "SELECT tos FROM offers WHERE campaign = `'$cid'`";$Offer = mysql_query($query_Offer, $Offer) or die(mysql_error());$row_Offer = mysql_fetch_assoc($Offer);$totalRows_Offer = mysql_num_rows($Offer);[/code]The error I get is as follows:[quote]Unknown column ''10000'' in 'where clause'[/quote]I have a text box that will be populated with the data being pulled form the above query in which I have the following code:[quote]<?php echo $row_Index['tos']; ?>[/quote]The table name is "offers" and the columns I am attempting to pull data from are "tos" and "campaign". The URL for this page is http://www.allinonevacations.net/collect.php?campaign=10000.Thanks. Quote Link to comment Share on other sites More sharing options...
obsidian Posted December 28, 2006 Share Posted December 28, 2006 Why do you have tics AND single quotes around your variable? When you're referencing a value in SQL, just use the single quotes. Change that up and see what you get:[code]SELECT tos FROM offers WHERE campaign = '$cid'[/code] Quote Link to comment Share on other sites More sharing options...
brettpower Posted December 28, 2006 Author Share Posted December 28, 2006 Good eyes. I thought that, too, as per the mySQL manual. However, for some reason, having both tics and quotes gets the URL variable to pull. Having only single quotes does remove the error message, but the URL variable does not pull. Quote Link to comment Share on other sites More sharing options...
brettpower Posted December 28, 2006 Author Share Posted December 28, 2006 I may have the problem solved. I reverted back to the syntax per the mySQL manpages, and did a little mod on some code in my text box. I may have it working..... Quote Link to comment Share on other sites More sharing options...
brettpower Posted December 28, 2006 Author Share Posted December 28, 2006 My PHP syntax in the text box was incorrect. Everything works great now! Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.