MySQL Forums
Forum List  »  PHP

Re: Selecting data works "SOMETIMES" ! with the code
Posted by: Chis Florinel
Date: August 23, 2005 08:07AM

Here is a code snipet:

[php]
//....
$sqlListUrl = "SELECT pesma, url FROM nostalgija WHERE pesma LIKE '%" . mysql_real_escape_string($st) . "%'";
$resultListUrl = mysql_query($sqlListUrl );

while ( $row = mysql_fetch_array($resultListUrl) ) {
echo "<a href='".$row["url"]."'>" . $row["pesma"] . "</a><br>";
}

//....
[/php]
As you can see I replaced " with ', after LIKE ...

mysql_real_escape_string() function is used to escape strings (is a basic protection for sql injection)

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.