Jump to content

All4172

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

All4172's Achievements

Member

Member (2/5)

0

Reputation

  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
×
×
  • 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.