Jump to content

morrism35

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by morrism35

  1. want to create a random image from these 5 images that I have in the template array every time I refresh the home page. here is my code. my output has been : $dir = "Images"; $DirEntries = scandir($dir, 1); $template=preg_grep('/^download\d+\.(gif|png|jpg)$/', $DirEntries); foreach($template as $temp){ shuffle($temp); echo <IMG SRC="'. $temp.'"alt="alt">'; }
  2. thank you I was able to use the preg_grep with a pattern similiar to what you have
  3. So to find all files with the name download and that are jpg, png, or gif this is the pattern? I've tried this and it is not finding it. $template=preg_grep('/^d\download\./(gif|jpg|png)$/, $Entry');
  4. Hello everyone, I'm trying to find all the files in my image folder and copy them into an array. The files have to start with "download" and have a "jpg, png, or gif extention". My code is listed below. I verified the code is correct till the foreach statement that does output the $entry array, however something is wrong when i use my preg_grep. It seems like it is not finding the files. I know their are other ways but my teacher wants me to use the pattern match and really in this course we haven't learned any of the advanced techniques that I found in my web searches on this issue. Thank you. $dir = "Images"; $DirEntries = scandir($dir, 1); foreach($DirEntries as $Entry){ $template=preg_grep('/^dog\d+\.(gif|jpg|png)$/', $Entry); echo $template; }
  5. Supposed to be an internal link and I just wrote it on this message board just to make things easier for everyone to see. In my program it is a seperate file. I'm really am not very strong in html. I took that course about a yr ago and it's really hurt my progress in php. My programming curriculum for my associates degree took me through a wide variety of computer languages so I really haven't had a chance to get a good grip on one language.
  6. Hey guys and girls I got it. Can't believe it was a simple file name on my web server that was wrong. Think I'm just burning out with php. I'm finding this language much more difficult to learn than java or C++. Not sure why.
  7. This needs to be at the top of all php coded pages. I'm only on the 5th chapter of the book, i've never heard of this. Should this be in a php tag. And is this the correct code: error_reporting(E_ALL); ini_set('display_errors', '1'); error_reporting(E_ALL); ini_set('display_errors', '1');
  8. Thanks but that only outputs a 1 when I click on the file. the code out of the book doesn't have a echo with that highlight statement. Could be bad code in the book. It's called PHP programming with mysql by Don Gossein. 90% of the reviews that I have read on Amazon have been very bad about this book, but that's what my MIA(no classmate has heard from him in a month) instructor wants us to use.
  9. Thank you, the no source found message is going but it just outputs a blank page. Everything looks like it should read my source_file and execute but still not sure why it's not outputting the source code for the file that I send it.
  10. It is supposed to output the source code of the file the I send to the get method with the highlights(caused by highlight_string)
  11. I have ran every combination for a value for my source_file but nothing is allowing my isset($_GET) to execute. The file runs but it only executes the else statement. This is code directly out of my text book for a Chinese Zodiac Discovery Project. <?php if(isset($_GET['source_file'])){ $SourceFile = file_get_contents( stripslashes($_GET['source_file'])); highlight_string($SourceFile); } else echo "<p>No source file name entered</p>\n"; ?> ___________________________________________________________ <div id-"string"> <a id="string">String Functions</a> <p>This script counts the number of times each letter appears in a string andcompares that count to the number of times </p> <a href="SimiliarNames.php">Test Similiar Names Script</a> //Source file <a href="ShowSourceCode.php"? source_file=SimiliarNames">[View the Source Code]</a> </div> <div id="char"> <a id="char">Character Functions</a> <p>This script finds the number of words embedded</p> <a href="EmbeddedWords.php">Test EmbeddedWords Script</a> //Source file <a href="ShowSourceCode.php"?source_file=EmbeddedWords">[View the Source Code]</a> </div>
  12. same file and I would never ask someone to right my code. I'm a grown midlife career changer not a high school or young college kid. What I would need a hand on is maybe some logic of how to go about this, not specific code unless I get really stuck like before. I have been on that previous assignments for quite a few days and wrote over 300 lines of code so no I'm not asking someone to do my work for me.
  13. Thank you so much, I really appreciate this. I never thought about trimming the file when using my if statement. Couldn't figure out why my if wasn't making the comparison correctly. I have struggled with php much more than i have with java or C++. It doesn't help that my instructor is hard to get in touch with and is always mia so I'm really teaching myself. One thing that I was supposed to do in this assignment was to store a running counter in a file for each year that the specific year was entered. My count.txt file only stores the year but not how many times it was entered. Example 1985 1999 etc. The assignment should say 1985-5 times or some type of format like that. Any help or pointing me in the correct directions would help.
  14. instructor wants us to display and write to a file how many times a certain year was entered by the user. My code is listed below. I left out of lot of the irrelevent code. I have the user selecting a birthyear and if the birthyear matches one of those birthyears in my "if" statement it displays an emage and writes that year to count. My instructor wants that txt file updated frequently with the year and how many times that number appears. I was able to get only far as reading the file and iterating it with a foreach and printing what is in the count.txt. I've been at this program for 4 days someone please help. Lost a lot a time with other assignments thanks to this assignments. if($BirthYear==2019 || $BirthYear==2007 || $BirthYear==1995 || $BirthYear==1983 || $BirthYear==1971){ $CountFile = 'statistics/count.txt'; if(file_exists($CountFile)){ echo"file accepted"; $handle = fopen('statistics/count.txt', 'a'); chmod("count.txt", 0777); fwrite($handle, $BirthYear. PHP_EOL); fclose($handle);} else{ mkdir("statistics"); $handle = fopen('statistics/count.txt', 'w'); chmod("", 0777); fwrite($handle, $BirthYear. PHP_EOL); fclose($handle);} echo "<p>You were born under the sign of the <img src='Images/pig-zodiac.jpg' alt='' />, </p>\n ";} $readin = file('statistics/count.txt'); foreach($readin as $year){ if($year == $BirthYear){ echo $year. $BirthYear;} } echo "You are person $count to enter $BirthYear"; EDIT: make use of our tags
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.