0

Hi there, for the life of me I can't work out what is wrong with this script, but when it runs I get this message.

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in....

<?

$q6 = "select * from banners where lang = \"$_SESSION[lang]\" and section = \"top\" ORDER BY RAND() limit 1"; 

$r6 = mysql_query($q6) or die(mysql_error(Error5));

while($a6 = mysql_fetch_array( $r6 )) 

{ 

echo "$a6[content]";

}

?>

If anyone can help it would be greatly appreciated.

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Facte
0

have you done a mysql_connect()?

Hi, yes I have a mysql_connect() it's part of a much larger script, but this is the section it says it has a problem with.

Thanks for your help though.

0

Try this:

$q6 = "SELECT * FROM banners WHERE lang='{$_SESSION['lang']}' AND section='top' ORDER BY RAND() LIMIT 1";
1

Please check if this works:

$lang = $_SESSION['lang'];

$q6 = sprintf("SELECT * FROM banners WHERE lang='%s' AND section='top' ORDER BY RAND() LIMIT 1",mysql_real_escape_string($lang));

Edited by webexpertzhere: n/a

Votes + Comments
What can I say. It solved my problem. Thanks
0

That fixed the problem. Thank you very much for your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.