Current location: Hot Scripts Forums » Programming Languages » PHP » If Statement !!!


If Statement !!!

Reply
  #1 (permalink)  
Old 08-29-06, 12:45 PM
phpfreek phpfreek is offline
Wannabe Coder
 
Join Date: Feb 2006
Posts: 113
Thanks: 0
Thanked 0 Times in 0 Posts
If Statement !!!

Hey everyone ... well, i am currently working on a new project, i hope this project is my biggest and best project yet ...

Well ... i will be asking a few questions here wich i will hope someone will help me with ... ok here's my first question :

Well ... i am trying to write a php code that will "print" or display a random image from a given folder (the folder contains many pics) ... that will be used to then use an IF Statement for "secure image verification" ... (to make sure that a person is filling the fields, and not a program) ...

So the code i failed to code ... is the one that will diplay a random image from a given folder ... if someone can write that, i would surely appreciate it ...

Thank you in advance
M.TARAKJI a.k.a PHPFREEK

P.S : nico_swd ... if you read this, please help me with it
Reply With Quote
  #2 (permalink)  
Old 08-29-06, 12:52 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Lol, this should do it.

PHP Code:

$dir './images/';


$images glob($dir '*.jpg');
$image $images[array_rand($images)];

echo 
$image
(You may need to change the extension)
Reply With Quote
  #3 (permalink)  
Old 08-29-06, 02:27 PM
phpfreek phpfreek is offline
Wannabe Coder
 
Join Date: Feb 2006
Posts: 113
Thanks: 0
Thanked 0 Times in 0 Posts
lol ... i mean what is there you can't do ???
btw ... that was also fast
Thanks bro ...
Reply With Quote
  #4 (permalink)  
Old 08-29-06, 05:07 PM
phpfreek phpfreek is offline
Wannabe Coder
 
Join Date: Feb 2006
Posts: 113
Thanks: 0
Thanked 0 Times in 0 Posts
I am sorry, bro but there seemd to be aproblem in your sript, i can't figure out what it is :s ... when i run the script, this is the message i get :
"$dir = './images/'; $images = glob($dir . '*.jpg'); $image = $images[array_rand($images)]; echo $image;" ... (without the qotes

Please review your script ...

Thanks again bro
Reply With Quote
  #5 (permalink)  
Old 08-29-06, 05:19 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Seems more like a usage error to me. I've tested it and it works.
Reply With Quote
  #6 (permalink)  
Old 08-29-06, 07:27 PM
phpfreek phpfreek is offline
Wannabe Coder
 
Join Date: Feb 2006
Posts: 113
Thanks: 0
Thanked 0 Times in 0 Posts
oh ok, good then ... i'll check wha mistake i have done

Thanks again for the help
Reply With Quote
  #7 (permalink)  
Old 08-29-06, 07:38 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
<?php
CODE
?>
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #8 (permalink)  
Old 08-30-06, 04:47 AM
phpfreek phpfreek is offline
Wannabe Coder
 
Join Date: Feb 2006
Posts: 113
Thanks: 0
Thanked 0 Times in 0 Posts
lol ... am not that dumb acecool ... anyway ... i found the problem ... it was with my host ... but thanks anyway
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP include not working in echo statement mike_jandreau PHP 6 04-03-07 05:02 AM
intermediate/advanced mysql statement todayscoffee PHP 1 05-09-06 02:32 PM
Malfunctioning switch statement and processing cstallins PHP 2 10-20-03 08:48 PM
If/else statement working...but not working mdhall PHP 13 10-16-03 08:47 AM
If then statement acting up! geneane ASP 1 09-30-03 04:32 PM


All times are GMT -5. The time now is 07:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.