Somebody please help me I'm going insane

Thread Solved

Join Date: Jul 2009
Posts: 23
Reputation: Facte is an unknown quantity at this point 
Solved Threads: 0
Facte's Avatar
Facte Facte is offline Offline
Newbie Poster

Somebody please help me I'm going insane

 
0
  #1
Oct 15th, 2009
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....

  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 60
Reputation: pclfw is an unknown quantity at this point 
Solved Threads: 5
pclfw pclfw is offline Offline
Junior Poster in Training
 
0
  #2
Oct 15th, 2009
have you done a mysql_connect()?
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 23
Reputation: Facte is an unknown quantity at this point 
Solved Threads: 0
Facte's Avatar
Facte Facte is offline Offline
Newbie Poster
 
0
  #3
Oct 15th, 2009
Originally Posted by pclfw View Post
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 525
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro
 
0
  #4
Oct 15th, 2009
Try this:
  1. $q6 = "SELECT * FROM banners WHERE lang='{$_SESSION['lang']}' AND section='top' ORDER BY RAND() LIMIT 1";
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 15
Reputation: webexpertzhere is an unknown quantity at this point 
Solved Threads: 6
webexpertzhere webexpertzhere is offline Offline
Newbie Poster
 
1
  #5
Oct 15th, 2009
Please check if this works:

  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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 23
Reputation: Facte is an unknown quantity at this point 
Solved Threads: 0
Facte's Avatar
Facte Facte is offline Offline
Newbie Poster
 
0
  #6
Oct 15th, 2009
That fixed the problem. Thank you very much for your help.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC