954,123 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Somebody please help me I'm going insane

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.

Facte
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

have you done a mysql_connect()?

pclfw
Junior Poster
133 posts since Jun 2005
Reputation Points: 33
Solved Threads: 9
 
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.

Facte
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Try this:

$q6 = "SELECT * FROM banners WHERE lang='{$_SESSION['lang']}' AND section='top' ORDER BY RAND() LIMIT 1";
Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

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));
webexpertzhere
Light Poster
27 posts since Oct 2009
Reputation Points: 11
Solved Threads: 9
 

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

Facte
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You