944,058 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 536
  • PHP RSS
Oct 15th, 2009
0

Somebody please help me I'm going insane

Expand Post »
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....

PHP Syntax (Toggle Plain Text)
  1. <?
  2.  
  3. $q6 = "select * from banners where lang = \"$_SESSION[lang]\" and section = \"top\" ORDER BY RAND() limit 1";
  4.  
  5. $r6 = mysql_query($q6) or die(mysql_error(Error5));
  6.  
  7. while($a6 = mysql_fetch_array( $r6 ))
  8.  
  9. {
  10.  
  11. echo "$a6[content]";
  12.  
  13. }
  14.  
  15. ?>

If anyone can help it would be greatly appreciated.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Facte is offline Offline
29 posts
since Jul 2009
Oct 15th, 2009
0
Re: Somebody please help me I'm going insane
have you done a mysql_connect()?
Reputation Points: 33
Solved Threads: 9
Junior Poster
pclfw is offline Offline
132 posts
since Jun 2005
Oct 15th, 2009
0
Re: Somebody please help me I'm going insane
Click to Expand / Collapse  Quote originally posted by pclfw ...
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.
Reputation Points: 10
Solved Threads: 0
Light Poster
Facte is offline Offline
29 posts
since Jul 2009
Oct 15th, 2009
0
Re: Somebody please help me I'm going insane
Try this:
PHP Syntax (Toggle Plain Text)
  1. $q6 = "SELECT * FROM banners WHERE lang='{$_SESSION['lang']}' AND section='top' ORDER BY RAND() LIMIT 1";
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Oct 15th, 2009
1
Re: Somebody please help me I'm going insane
Please check if this works:

php Syntax (Toggle Plain Text)
  1. $lang = $_SESSION['lang'];
  2.  
  3. $q6 = sprintf("SELECT * FROM banners WHERE lang='%s' AND section='top' ORDER BY RAND() LIMIT 1",mysql_real_escape_string($lang));
Last edited by webexpertzhere; Oct 15th, 2009 at 1:20 pm.
Reputation Points: 11
Solved Threads: 9
Light Poster
webexpertzhere is offline Offline
27 posts
since Oct 2009
Oct 15th, 2009
0
Re: Somebody please help me I'm going insane
That fixed the problem. Thank you very much for your help.
Reputation Points: 10
Solved Threads: 0
Light Poster
Facte is offline Offline
29 posts
since Jul 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP equivalent for unescape()
Next Thread in PHP Forum Timeline: template system





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC