Author Topic: Basic php and mysql question  (Read 8838 times)

0 Members and 1 Guest are viewing this topic.

Offline ilaslan

  • Newbie
  • *
  • Posts: 44
    • View Profile
Basic php and mysql question
« 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$kacisininteger ); 

 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 

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Basic php and mysql question
« Reply #1 on: January 25, 2011, 03:04:55 PM »
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);
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ilaslan

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Basic php and mysql question
« Reply #2 on: January 25, 2011, 05:38:34 PM »
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.................................

« Last Edit: January 25, 2011, 06:21:41 PM by ilaslan »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)