Jump to content

All4172

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by All4172

  1. That gets me to match it...but how do I phrase it in order to keep the letters though? In the example above I need to somehow keep the ABCDE in order to apend it with the .php on the end.
  2. What I"m wanting to do is to take: /q?s=ABCDE and to change it to /mydirectory/ABCDE.php Sometimes the file is 3 letters sometimes 4 and other times five. What is the correct regex to use in a preg_replace / str_replace function?
  3. That worked great. Is there anything like that to convert capital letters to lower case?
  4. What I'm trying to do is search a field in mysql, and if it has an _ in the file name, change it to a - instead. And alos change any capital letters to lower case. From: This_is_my_example To : this-is-my-example I figure it would be something like: UPDATE 'file' SET '-' WHERE `filename` LIKE '_' I"m not really sure how to put a regular expression in there to only replace the underscore put leave the data.
  5. I know that portion but for this site its on a shared host. So access to the .ini file isn't possible. Reason I asked if possible to add anything to the script.
  6. I'm working with a simple upload script where users can upload pic files and the rest. The pics are of professional variety so they can be quite large (20MB -60MB). When I run a test file that is around 3-5 MB's it'll upload fine. However, when I began to attempt to upload files that are 15-20+ MB's it seems to do nothing. I'm guessing the server is timing out? Is there anything I can add to the below script so a server doesn't time out? <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']); $ok=1; $uploaded_size = $_FILES['uploaded']['size']); if ($uploaded_size > 70000000) { echo "Your file is too large. Max file size is 70MB and your file was $uploaded_size<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "Target Path - "; echo $target; echo "<BR>File Size - "; echo $uploaded_size; echo "<BR>File Name - "; echo basename( $_FILES['uploaded']['name']); } else { echo "Sorry, there was a problem uploading your file."; } } ?>
  7. What I'm wanting to do is a statement like: $file = "/path/www/mydir/3429438.php"; if ($file == "/path/www/mydir/"){ $file = "/path/www/NEWmydir/3429438.php;} Quesiton is what regular expression in the if statement so it'll search /[0-9].php and how to take that filename and apend it on the new $file if the instance exists. Ideas?
  8. Thanks for that. That did the trick with a few minor adjustments. I'll defantly have to study what you put together as some the things such as $d->path; and isset($_GET['p']) ? $_GET['p']:1; (the ? in the middle) I'm not familiar with.
  9. I see what your saying. I've modified it to: if ($single_page == "1") { $min_num = 1;} else { $min_num = ($single_page - 1) * 25;} Also after doing further tests, if I change it from while ($t >= $min_num && $t < $max_num) to while ($t < $max_num) it'll work. Seems that when the script from page 2 on it sees $t as 0 again and doesn't not executue the while statement at all. I was under the assumption it would loop through till the min start, and then loop out until the max. Hmm any ideas?
  10. I have it as $single_page = 1; above the while statement in the code unless you meant something else is set to 0 above?
  11. What I'm trying to do, is look through a directory, grab all the files, store it into a variable, then divide the total number of files by 25 (the amount I want on each page) then echo it onto each page. I have everything set up thus far, however, I seem to be only able to get the 1st page to show the 1-25 and each page thereafter shows up blank. I think the problem is where I call if ($_GET["page"]==$single_page). I've tried changing that to WHILE but it ends up looping till I get a 30 second timeout. Any ideas or suggestions? <?php $i = 0; $t = 0; if ($handle = opendir('/home/webpath/www/mydir')) { // List all the files while (false !== ($file = readdir($handle))) { if(preg_match('/(\.php)$/i',$file)) { $file1 = str_replace(".php", '', $file); $list_array[$i] = '<a href="http://www.example.com/mydir/'.$file.'">'.$file1.'</a><p>'; $i++; }}} closedir($handle); echo "Total files: ".$i."<P>"; $pages = $i / 25; $pages = (ceil($pages)); sort($list_array); $single_page = 1; while ($pages >= $single_page) { if ($_GET["page"]==$single_page) { $min_num = ($single_page - 1) * 25; $max_num = $single_page * 25; echo "Min: ".$min_num."<p>"; echo "Max: ".$max_num."<p>"; while ($t >= $min_num && $t < $max_num) { echo "<p><li>".$list_array[$t]; $t++; } } $single_page++; } ?>
  12. Reason i can't do it that way is I need to retrieve the articles epoch date and compare it to the servers epoch date before I can change its status. So that's the reason I had to break up the queries. There most likely is an easier and cleaner way of doing it but right now its beyond me. Changing to mysql_query($query); did the trick. I just overlooked it.
  13. What I'm trying to do, is if a condition is met, then update the mysql db. So I have the following: $server_date = date('U'); $result = mysql_query("SELECT * FROM article WHERE status LIKE 'notlive' AND date>0"); while($row = mysql_fetch_array($result)) { if ($server_date >= $row['date']) { echo "Changed<BR>"; $query = "UPDATE article SET status = 'live' WHERE status='notlive'"; mysql_fetch_array($query);} } I know the condition is met since it displays "Changed" twice, but the UPDATe doesn't appear to go through. Am I able to send an UPDATE in the WHILE statement?
  14. The AND is what I needed. For those that may find this later on when searching. I ended up doing this: $result = mysql_query("SELECT * FROM article WHERE visiblity LIKE 'notlive' AND date>0"); while($row = mysql_fetch_array($result)) { echo $row['date']; echo "<br />"; }
  15. Table = article fields = id, visiblity, date idvisibiltydate 1live1181639193 2notlive1173638815 Based on the info above, if field visiblity is = notlive then I want to retrieve the data from date. Hope that clarifies
  16. What I'm wanting to do, is set up a mysql_query but based on two WHERE's. $result = mysql_query("SELECT * FROM article WHERE visiblity LIKE 'notlive'"); Then if I have a $result from that query, I want to get a value in that same row from another cell called date but in the same row. Is there a way to set up WHERE to say visiblity like 'notlive' get value from epoch date in table DATE.
  17. The phpbb mod boards is a better place to ask this question since its no php related.
  18. I have a value for a filename called $foo. I want to put the value of $foo in a href but can't seem to get it to work. I've tried this: echo "<a href=\"javascript:poptastic('/email/$foo');\"> < But no luck
  19. I want to echo just the filename of a current page. When I use something like $_SERVER['PHP_SELF'] it gives the directory and the filename. Any ideas on how to show JUST the filename?
  20. Hi Ted, What I'm trying to do is use touch with a multi demensional array. Basically I do a preg_match_all earlier in the script that outputs the data to a multi-dimensional array. I can echo that multi-dimensional array and it works fine. But now I'm trying to take that array and use touch(), and create a file with that name. The value of that multi-dimensional array is always 4 letters. Right now when I use touch with that multi-dimensional array [ touch ($body[0][$i].".php"); ] it creates nothing. However when I just say something like [ touch($body[0][$i]); ] it'll create but it creates it as Array[0] Array[1] ect. So basically I'm trying to find out how to create files with a multi dimensional array with the value of the array that I echo.
  21. Not the problem again. That's the whole area of code that involves the while statement. I'm not gonna post over 1200 lines of code. My question is simple really. How to create a file with a multi dimensional array using touch.
  22. I didn't post the whole code, just the part with the problems. Its not an indefinate loops. Also the reason for the muli-dimensional array is that is what you get when you pull data from pret_match_all. I can't use numbers, but want to use the $i portion. It properly echo's the correct values (such as: AMPS, or DMPS ect). I can't use numbers for it either . Here's the entire for statement of code: $filename = "gainers.txt"; if (!file_exists($filename)) { touch($filename); // Create blank file chmod($filename,0777); } $fp = fopen( $filename, 'w'); $i = 0; while ($i < 10) { fwrite ( $fp, $name[0][$i] ); echo $name[0][$i]; fwrite ( $fp, "&nbsp (" ); echo "&nbsp &#40"; fwrite ( $fp, $body[0][$i] ); echo $body[0][$i]; touch("as".$body[0][$i].".php"); fwrite ( $fp, ") $nbsp" ); echo ") &nbsp"; $i++;} fclose ( $fp );
  23. Still no luck. I also tried: touch("ab".$body[0][$i].".php"); No luck with that one either. Very strange...
  24. Nope...when I have it as: touch("$body[0][$i].php"); It creates files names such as Array[0].php ect. When I try it as: touch($body[0][$i].".php"); Nothing is created still....
  25. According to my book it says "If a file does not yet exist, you can create one with the touch() function. Given a string representing a file path, touch() attempts to create an empty file of that name." I also know touch does that since it works when I have: $filename = "test.php"; if (!file_exists($filename)) { touch($filename); chmod($filename,0777); The code you offered just returns a "can't open file". So its not creating a file.
×
×
  • 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.