Page 1 of 3

array!!?

Posted: Fri Dec 17, 2004 5:31 pm
by BT-loader
I got this when i tried to fix a cam-portal (24 Update Cam Portal Script v 3.3).

Code: Select all

Warning: extract(): First argument should be an array in /home/PROTECTED/public_html/PROTECTED/mods/stats.php on line 42 
Det finns totalt 1 medlemmar i portalen. 
Det finns totalt 10 kategorier från 1 olika länder. 
Det finns totalt Totalt bilder cam images in the member archives. 
 
Warning: extract(): First argument should be an array in /home/PROTECTED/public_html/PROTECTED/mods/stats.php on line 85 
Det finns totalt Totalt bilder nya bilder idag. 
 
Warning: extract(): First argument should be an array in /home/PROTECTED/public_html/PROTECTED/mods/stats.php on line 99 
Det finns totalt Totalt bilder B image transfer in .
stats.php

Code: Select all

<? 
$update1 = "update db_cam_total set total_images = '0' where id = 'total'"; 
@mysql_query($update1); 
$query = @mysql_query("SELECT id FROM db_cam WHERE active = '1' GROUP BY id"); 
while ($rows = mysql_fetch_array($query)){ 
$user_id = $rows[id]; 
$nums = @mysql_query("SELECT id from db_cam_image_$user_id"); 
$num_rows = @mysql_num_rows($nums); 
$res1 = @mysql_query("select total_images from db_cam_total WHERE id = 'total'"); 
@extract(mysql_fetch_array($res1)); 
$new_total = $num_rows + $total_images; 
$update2 = "update db_cam_total set total_images = '$new_total' where id = 'total'"; 
@mysql_query($update2); 
} 
?> 
 
<CENTER> 
<TABLE WIDTH="400" BORDER="0" CELLSPACING="0" CELLPADDING="2"> 
<TR> 
<TD WIDTH="100%" BGCOLOR="<? echo "$TD_color2"; ?>"> 
<B><FONT COLOR="<? echo "$text_color1"; ?>" SIZE="-1" FACE="<? echo "$font_type"; ?>"><? echo "$stats_header"; ?></FONT></B></TD> 
</TR> 
<TR> 
<TD WIDTH="100%" BGCOLOR="<? echo "$TD_color1"; ?>"> 
<FONT COLOR="<? echo "$text_color2"; ?>" SIZE="-1" FACE="<? echo "$font_type"; ?>"> 
<? 
 
$num1 = "SELECT id from db_cam_cat"; 
$nums1 = mysql_query($num1); 
$num_rows1 = mysql_num_rows($nums1); 
 
$num2 = "SELECT id from db_cam GROUP BY country"; 
$nums2 = mysql_query($num2); 
$num_rows2 = mysql_num_rows($nums2); 
 
$num3 = "SELECT id from db_cam"; 
$nums3 = mysql_query($num3); 
$num_rows3 = mysql_num_rows($nums3); 
 
$q2 = "select total_images from db_cam_total WHERE id = 'total'"; 
$res2 = mysql_query($q2) or die(mysql_error()); 
extract(mysql_fetch_array($res2)); 
 
echo "$there_are_total $num_rows3 $cam_m_in_portal<BR>"; 
echo "$there_are_total $num_rows1 $categorys_from $num_rows2 $different_countrys<BR>"; 
echo "$there_are_total $total_images $cam_i_in_m_archives<BR>"; 
 
 
// Images today start 
// GMT time start 
$gmt_user = $HTTP_COOKIE_VARS["gmt_client"]; 
if ($gmt_user == ""){ 
$gmt_client = date("d-m-Y"); 
} else { 
$arrgmt = array("-12"=>"-12", "-11"=>"-11", "-10"=>"-10", "-9"=>"-9", "-8"=>"-8", "-7"=>"-7", "-6"=>"-6", "-5"=>"-5", "-4"=>"-4", "-3"=>"-3", "-2"=>"-2", "-1=">"-1", "+0"=>"0", "+1"=>"1", "+2"=>"2", "+3"=>"3", "+4"=>"4", "+5"=>"5", "+6"=>"6", "+7"=>"7", "+8"=>"8", "+9"=>"9", "+10"=>"10", "+11"=>"11", "+12"=>"12"); 
$gmt = $arrgmt[$gmt_user]; 
$gmt_a = $gmt-$server_GMT; 
$gmt_b = $gmt-$server_GMT; 
$user_hdiff = $gmt_a-$gmt_b; 
$gmt_client = date("d-m-Y", time()+$user_hdiff*3600); 
} 
// GMT time end 
 
$month_reset_time = time(); 
$resh = @mysql_query("select month_reset from db_cam_total WHERE id = 'total_today'"); 
@extract(mysql_fetch_array($resh)); 
if($month_reset_time - $month_reset > 10800){ 
$update3 = "update db_cam_total set total_images = '0' where id = 'total_today'"; 
@mysql_query($update3); 
$queryz = @mysql_query("SELECT id FROM db_cam WHERE active = '1' GROUP BY id"); 
while ($rowz = @mysql_fetch_array($queryz)){ 
$useridz = $rowz[id]; 
$numsz = @mysql_query("SELECT id FROM db_cam_image_$useridz WHERE date = '$gmt_client'"); 
$num_rows_today = @mysql_num_rows($numsz); 
$resg = @mysql_query("select total_images from db_cam_total WHERE id = 'total_today'"); 
@extract(mysql_fetch_array($resg)); 
$new_total_today = $num_rows_today + $total_images; 
$update4 = "update db_cam_total set total_images = '$new_total_today',month_reset = '$month_reset_time' where id = 'total_today'"; 
@mysql_query($update4); 
} 
} 
 
$qu = "select total_images from db_cam_total WHERE id = 'total_today'"; 
$resu = mysql_query($qu) or die(mysql_error()); 
extract(mysql_fetch_array($resu)); 
echo "$there_are_total $total_images $new_cams_today<BR>"; 
// Images today end 
 
// Setup some common file size measurements. 
$kb = 1024;         // Kilobyte 
$mb = 1024 * $kb;   // Megabyte 
$gb = 1024 * $mb;   // Gigabyte 
$tb = 1024 * $gb;   // Terabyte 
 
// Get the file size in bytes. 
 
$q1 = "select total_images,month_reset from db_cam_total WHERE id = 'total_kb'"; 
$res1 = mysql_query($q1) or die(mysql_error()); 
extract(mysql_fetch_array($res1)); 
 
$size = "$total_images"; 
 
if($size < $kb) { 
$size = $size." B"; 
} else if($size < $mb) { 
$size = round($size/$kb,2)." KB"; 
} else if($size < $gb) { 
$size = round($size/$mb,2)." MB"; 
} else if($size < $tb) { 
$size = round($size/$gb,2)." GB"; 
} else { 
$size = round($size/$tb,2)." TB"; 
} 
 
$monthName = array(01=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");  
    
$monthname=("$monthName[$month_reset]"); 
 
echo "$there_are_total $size image transfer in $monthname."; 
?> 
</FONT></TD> 
</TR> 
</TABLE> 
</CENTER>
Please explain what i need to do, cause i can´t much about php. :cry:

Posted: Fri Dec 17, 2004 5:45 pm
by andre_c
try changing all mysql_fetch_array to mysql_fetch_assoc
I don't think extract likes the array with the indices included

Posted: Fri Dec 17, 2004 5:54 pm
by BT-loader
andre_c wrote:try changing all mysql_fetch_array to mysql_fetch_assoc
I don't think extract likes the array with the indices included
Ok! Thanks for the fast reply, hope it helps...!? :?

Posted: Fri Dec 17, 2004 6:03 pm
by BT-loader
Nope, that didn´t help. :(

Posted: Fri Dec 17, 2004 6:06 pm
by andre_c
try doing a print_r instead of extract and post what you get

Posted: Fri Dec 17, 2004 6:09 pm
by BT-loader
andre_c wrote:try doing a print_r instead of extract and post what you get
Sure...! But where am i supposed to write "print_r"?? :oops:

Nevermind, i didn´t read the WHOLE answer. :roll:

Posted: Fri Dec 17, 2004 6:12 pm
by andre_c
on line 42, instead of doing

Code: Select all

<?
extract(mysql_fetch_array($res2)); 
?>
do

Code: Select all

<?
echo "<pre>\n";
print_r(mysql_fetch_array($res2)); 
?>

Posted: Fri Dec 17, 2004 6:14 pm
by BT-loader
YES!!! The last thing with the "print_r" really helped.

You´re the BEST man! ;)

Posted: Fri Dec 17, 2004 6:18 pm
by BT-loader
Since you where both fast and great with your replies, i thought i give it on other try. :)

I have some other minor error in my php-code, and i was hoping you could help me with them to???

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/PROTECTED/public_html/PROTECTED/edit_main.php on line 1349

This is the row:

Code: Select all

while ($rowb = mysql_fetch_array($queryb))&#123;

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/PROTECTED/public_html/PROTECTED/edit_main.php on line 1245

This is the row:

Code: Select all

while ($rowsa = mysql_fetch_array($querya))&#123;

Posted: Fri Dec 17, 2004 6:20 pm
by andre_c
sounds like you have a problem when executing the query, make sure you do:

Code: Select all

<?
$queryb = mysql_query( /*-- your query statement --- */ ) or die( mysql_error() );
?>

Posted: Fri Dec 17, 2004 6:24 pm
by BT-loader
andre_c wrote:sounds like you have a problem when executing the query, make sure you do:

Code: Select all

<?
$queryb = mysql_query( /*-- your query statement --- */ ) or die( mysql_error() );
?>
What do you mean by that? 8O

Posted: Fri Dec 17, 2004 6:25 pm
by andre_c
can you post the code around line 1245?

Posted: Fri Dec 17, 2004 6:28 pm
by BT-loader
andre_c wrote:can you post the code around line 1245?
Sure mate, sorry about that. :wink:

Code: Select all

<?
$querya = mysql_query("SELECT * FROM db_cam_amazon WHERE amazon_user = '$id' ORDER BY amazon_id DESC LIMIT 0,30");
while ($rowsa = mysql_fetch_assoc($querya))&#123;

$amazon_asin = $rowsa&#1111;amazon_asin];
$amazon_title = $rowsa&#1111;amazon_title];
$amazon_cat = $rowsa&#1111;amazon_cat];

if($amazon_cat=="books")&#123;
$amazon_cat_text = "$books_text";
&#125; else if($amazon_cat=="classical")&#123;
$amazon_cat_text = "$classical_text";
&#125; else if($amazon_cat=="dvd")&#123;
$amazon_cat_text = "$dvd_text";
&#125; else if($amazon_cat=="videogames")&#123;
$amazon_cat_text = "$videogames_text";
&#125; else if($amazon_cat=="music")&#123;
$amazon_cat_text = "$music_text";
&#125; else if($amazon_cat=="software")&#123;
$amazon_cat_text = "$software_text";
&#125; else if($amazon_cat=="vhs")&#123;
$amazon_cat_text = "$vhs_text";
&#125; else &#123;
$amazon_cat_text = "NO INFO";
&#125;

echo

Posted: Fri Dec 17, 2004 6:30 pm
by andre_c
try adding: or die( mysql_error() ); like this:

Code: Select all

<?
$querya = mysql_query("SELECT * FROM db_cam_amazon WHERE amazon_user = '$id' ORDER BY amazon_id DESC LIMIT 0,30") or die( mysql_error() );
?>

Posted: Fri Dec 17, 2004 6:35 pm
by BT-loader
I think that helped, but no i got an other "error".

Code: Select all

Unknown column 'amazon_user' in 'where clause'