4images Forum & Community
General / Allgemeines => Programming => Topic started by: ilaslan on January 25, 2011, 02:41:03 PM
-
Sorry
i need help
in function.php and in a function. i am using this
$sql = "SELECT olacak
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id
ORDER BY olacak ASC";
$image_row = $site_db->query_firstrow($sql);
$olacak_min = $image_row['olacak'];
$sql = "SELECT image_downloads
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id
ORDER BY image_downloads DESC";
$image_row = $site_db->query_firstrow($sql);
$download_max = $image_row['image_downloads'];
$downadd = $olacak_min / $download_max;
$sql = "SELECT image_downloads, image_hits, alioldu, aliresim, olacak, yuzdepuan
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
$kacisin = $image_row['olacak'];
$kacisin = $kacisin - ( $image_downloads * $downdanekle );
$kacisin = sprintf("%1\$u", $kacisin); // <<<<<< this was problem
..........
$yeni_yuzdepuan = sprintf("%.2f", $yeni_yuzdepuan);
$sql = "UPDATE ".IMAGES_TABLE."
SET alioldu = olacak = '$kacisin', yuzdepuan = '$yeni_yuzdepuan'
WHERE image_id = $image_id";
$site_db->query($sql);
in my phpmyadmin olacak int(11) so integer
i try too $kacisin = settype( $kacisin, integer );
but always 1 came. kacisin is normally.
300.434769
php is bad language, basic command i try to find internet gogle.. but alwayss bla bla bla. too php.net
which command i can use? $kacisin = sprintf("%1\$u", $kacisin); // <<<<<< this was problem
is mistakes
also
$kacisin = sprintf("%d", $kacisin); // <<<<<< this was problem
-
you forgot to mention what exactly you are looking for...so, pick one:
$kacisin = intval($kacisin);
$kacisin = (int)$kacisin; //same as the above but 300% to 650% faster
$kacisin = round($kacisin);
$kacisin = floor($kacisin);
$kacisin = ceil($kacisin);
$kacisin = abs($kacisin);
-
Hello vano
i chanced this code in download.php
if ($user_info['user_level'] != ADMIN) {
$sql = "UPDATE ".IMAGES_TABLE."
SET image_downloads = image_downloads + 1
WHERE image_id = $image_id";
$site_db->query($sql);
}
from this
if ($user_info['user_level'] != ADMIN) {
//olacak was created . in mysql olacak is integer --> int(11) . and showed this number quality of pic.
//This number is min photo is quality. some pics olacak's worth 305 , 499, 509, 566, 1000,1455,8787, 9000,.....
//default 12000
$sql = "SELECT olacak
FROM ".IMAGES_TABLE."
WHERE i.image_active = 1
ORDER BY olacak ASC";
$image_row = $site_db->query_firstrow($sql);
$olacak_min = $image_row['olacak']; // this must 300 because min olacak worth is = 305
$sql = "SELECT image_downloads
FROM ".IMAGES_TABLE."
WHERE i.image_active = 1
ORDER BY image_downloads DESC";
$image_row = $site_db->query_firstrow($sql);
$download_max = $image_row['image_downloads']; // this one must 15. because max image_downloads = 15
$downdanekle = $olacak_min / $download_max; // 305/15 = 20.333333 (i dont know exatly )
$sql = "SELECT olacak
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
$kacisin = $image_row['olacak']; // i want to read old olacAKs worth ( this pic old quality ) maybe 500
$kacisin = $kacisin - $downdanekle ); // i want to calculate new quality $kacisin = 500 - 20.3333 = 470.666
$kacisin = (int)$kacisin; // i want this $kacisin =470 for to write mysql olacak int(11)
$sql = "UPDATE ".IMAGES_TABLE."
SET image_downloads = image_downloads + 1, olacak = '$kacisin'
WHERE image_id = $image_id";
$site_db->query($sql);
}
result is unexpected error occured . and not download.
i hope i can explain.
result is this
An unexpected error occured. Please try again later.
An unexpected error occured. Please try again later.
ÿØÿàJFIFÿş;CREATOR: gd-jpeg v1.0 (using IJG JPE.................................
-
An unexpected error occured. Please try again later (http://www.4homepages.de/forum/index.php?topic=24177.0)