help in this code?????

Started on the old forum in July 2010 · view the original in the archive · old links redirect here

6 replies · 412 views · started 16 years ago · 1 min read

5 participants
slowy Senior · 357 posts #1
<?

$result_get_user_info = mysql_query("SELECT * FROM users WHERE id='$uid'");
$user_info = mysql_fetch_array($result_get_user_info);

$result_get_banner = mysql_query("SELECT user_login FROM users WHERE imp_left > 0 AND act='1' AND numban > 0");

while ($banner = mysql_fetch_array($result_get_banner)){
$bid[] = "$banner[user_login]";
}
$ip = getenv ("REMOTE_ADDR");
srand ((float)microtime()*1000000);
shuffle ($bid);
srand ((float)microtime()*1000000);
shuffle ($bid);

$id = "$bid[0]";
$id2 = "$bid[1]";

$checkban = "$banner[lastbannerid]";
If ($id == "$checkban"){
$id = "$bid[1]";
}

ElseIf ($id == ""){
$id = "$bid[1]";
}

ElseIf ($id != "$checkban" || $id != ""){}

mysql_pconnect("$dbhost", "$dbuser", "$dbpass")
			or die ("Unable to connect to database.");
		mysql_select_db("$dbname")
			or die ("Unable to select database.");
If ($id != "$user_info[user_login]"){
$result_get_banner_info = mysql_query("SELECT * FROM banners WHERE user='$id'");

$banner_info = mysql_fetch_array($result_get_banner_info);
}
If ($id == "$user_info[user_login]"){
mysql_pconnect("$dbhost", "$dbuser", "$dbpass")
			or die ("Unable to connect to database.");
		mysql_select_db("$dbname")
			or die ("Unable to select database.");
$result_get_banner_info = mysql_query("SELECT * FROM banners WHERE user='$id2'");
$banner_info = mysql_fetch_array($result_get_banner_info);
}

?>

its giving error in line 13 and 15

Warning: shuffle() expects parameter 1 to be array, null given in /public_html/abc/inc/showbanner/getbanner.inc on line 13

Warning: shuffle() expects parameter 1 to be array, null given in /public_html/abc/inc/showbanner/getbanner.inc on line 15

line #13 and 15 are shuffle ($bid);

subzero Super moderator Fellow · 3,954 posts #2
<? 

$result_get_user_info = mysql_query("SELECT * FROM users WHERE id='$uid'"); 
$user_info = mysql_fetch_array($result_get_user_info); 

$result_get_banner = mysql_query("SELECT user_login FROM users WHERE imp_left > 0 AND act='1' AND numban > 0"); 

while ($banner = mysql_fetch_array($result_get_banner)){ 
$bid[] = "$banner['user_login']"; 
} 
$ip = getenv ("REMOTE_ADDR"); 
srand ((float)microtime()*1000000); 
shuffle($bid); 
srand ((float)microtime()*1000000); 
shuffle($bid); 

$id = "$bid[0]"; 
$id2 = "$bid[1]"; 

$checkban = "$banner[lastbannerid]"; 
If ($id == "$checkban"){ 
$id = "$bid[1]"; 
} 

ElseIf ($id == ""){ 
$id = "$bid[1]"; 
} 

ElseIf ($id != "$checkban" || $id != ""){} 

mysql_pconnect("$dbhost", "$dbuser", "$dbpass") 
            or die ("Unable to connect to database."); 
        mysql_select_db("$dbname") 
            or die ("Unable to select database."); 
If ($id != "$user_info[user_login]"){ 
$result_get_banner_info = mysql_query("SELECT * FROM banners WHERE user='$id'"); 

$banner_info = mysql_fetch_array($result_get_banner_info); 
} 
If ($id == "$user_info[user_login]"){ 
mysql_pconnect("$dbhost", "$dbuser", "$dbpass") 
            or die ("Unable to connect to database."); 
        mysql_select_db("$dbname") 
            or die ("Unable to select database."); 
$result_get_banner_info = mysql_query("SELECT * FROM banners WHERE user='$id2'"); 
$banner_info = mysql_fetch_array($result_get_banner_info); 
} 

?>

Trail how to use shuffle function

<?php
$my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse");

shuffle($my_array);
print_r($my_array);
?>

The output of the code above could be:

Array ( [0] => Cat [1] => Horse [2] => Dog )

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

syrus Junior · 44 posts #5

The awnser is there, bid is null that means u have a broken query or bid wasnt set properly

something else Fellow · 2,296 posts #6

$result_get_banner = mysql_query("SELECT user_login FROM users WHERE imp_left > 0 AND act='1' AND numban > 0");

is only selecting 1 item so there is no $bid[1]

Anshul Senior · 296 posts #7

$result_get_banner = mysql_query("SELECT user_login FROM users WHERE imp_left > 0 AND act='1' AND numban > 0"); is this query right ? write

echo mysql_error();

below maybe there is no results for this query

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close