View Full Version : Trouble with MYsql in php.

04-17-2012, 10:37 PM
$sql2 = "SELECT DISTINCT `IP`, `Edition` FROM `Downloads` WHERE `Edition` = \'".$issue."\'";
$result2 = mysql_query($sql2);
while ($row2 = mysql_fetch_array($result2))
echo '<a href="Admin.php?Issue=' . $issue . '&IP=' . $row2['IP'] . '">' . $row2['IP'] . '</a></br>';

This is what i am having trouble with. When i execute the above SQL statement directly in MySQL it will execute properly (obviously removing the $issue for the value it could be. ) but i get nothing when i run in PHP. No errors no code nothing.

I have checked to ensure the $sql2 statement is generated correctly and it is for when it goes in to the mysql_query.

any idea what im doing wrong? Thanks.

04-17-2012, 10:57 PM
Remove the \ from the \'. Those are literal and not escapes since the entire string is double quoted.
Use $result2 = mysql_query($sql2) or die(mysql_error()); to show the error.

04-17-2012, 11:07 PM
thank you very much!