Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Random image naming script Help
Old 04-09-2005, 07:59 AM Random image naming script Help
Experienced Talker

Posts: 37
Trades: 0
I have the following code the create random images with unique names to it, the script supposed to name the image files with a combination of the STOCK and a incremental number, for example:

Stock Number = 200
Will create 3 images like 200-1.jpg, 200-2.jpg and 200-3.jpg

My problem is this code is creating only the first file 200-1.jpg when I upload the 2nd file still it is naming the 1st.

Please help me to fix this code so that everything I execute this the image numbering should be incremental

PHP Code:
if($image && isset($_REQUEST['itemcode'])) { 

   
$link mysql_connect($dbhost$dbuser$dbpass); 
    
$result mysql_db_query($dbname"select stock from $dbvin where itemcode='"$itemcode ."'"$link); 

    if ( 
mysql_num_rows($result) ) { 
       
$data mysql_fetch_assoc($result); 

       
$i 1
       
$error false
        
       while ( 
false == $error ) { 
         echo 
$i '<br>'
         if ( !
file_exists('./temp/' $data['stock'] . '-' $i '.jpg') ) { 
            echo 
'exists: ' './temp/' $data['stock'] . '-' $i '.jpg<br>'
            
$i++; 
            break; 
         } 
         
$i++; 
       } 
        
      
$icode $data['stock'] . '-' $i
smartcard is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Random image naming script Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13723 seconds with 12 queries