Jump to content

Saurdo

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

About Saurdo

  • Birthday 03/09/1990

Contact Methods

  • AIM
    Saurdo
  • MSN
    saurdoz@msn.com
  • Website URL
    http://www.saurdo.com
  • ICQ
    290784692
  • Yahoo
    Saurdoz

Profile Information

  • Gender
    Male
  • Location
    California

Saurdo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes, I used the first online tool I found on Google. Turns out the solution was much simpler. It is the difference between: header("Content-Length: " . filesize("34Box.mp3")); and header("Content-Length: " . filesize("34Box.mp3").";"); When I pasted the code into my previous post I removed the extra ."; " thinking that it was just extraneous and having no knowledge of its actual effect. Thanks for the help. Next time I'll make sure to paste my code exactly as i have it in the file.
  2. Thanks for the quick reply. Those three lines are literally everything in my php file. I'm using PHP v.5.2.6 with Apache v.2.0.63 on a Linux box. It's broken on my local WAMP server as well. I just did the file size comparison and unfortunately (because that would have at least given us a lead) everything matches.
  3. So while passing an mp3 file through php I noticed that the combination of Firefox and quicktime has quite the unusual bug. It apparently won't load all the way. It will load infinitely and only play the first couple seconds of the file. This apparently only occurs in Firefox. It works in IE8, IE7, IE6, Opera, and Chrome. I haven't tested it in different versions of Firefox though. Here's my three lines code: header("Content-type: audio/mpeg"); header("Content-Length: " . filesize("34Box.mp3")); readfile("34Box.mp3"); You can hear for yourself here: http://www.saurdo.com/test/phpmp3/test.php And before you start thinking that the mp3 is being distorted; it's supposed to sound like that. So, has anyone seen this problem before? And if so how was it fixed?
  4. I don't think you understood my question, at all. I don't care about writing it to a file, that's just for debugging purposes. I want to rewrite it to another database table but when i fetch the rows they aren't the same as when they're in the database.
  5. Hello! I'm attempting to convert my database away from wordpress format. Wordpress just feels too bloated and slows down my site a lot so I'm scrapping it. I'm trying to convert the database with a php script that selects the rows I want from the posts table in the wordpress database and inserts it into another database table in a different database I already made. The problem is that when fetching the current content it seems to convert it so two single quotes next to eachother turns into one and \r\n turns into a new line (when viewing in a text editor). Here's an example. The original database table: (4, 1, '2005-12-19 20:42:39', '2005-12-20 04:42:39', 'Check out this video of me killing some zombies. Eric recorded it and It''s only thirty seconds long. I''m going to be mean and embed it. \r\n\r\n<center><embed SRC="http://atlas.walagata.com/w/saurdo/zombie.wmv" width="320" height="240" loop="false" volume="100%" autostart="false" ></embed>\r\nPress play</center>\r\n\r\nHe added some funky music i provided and I compressed it to one megabyte so it would be painless to download. It''s not very exciting but zombies are cool. I was worried they''d kill Eric because they seemed so attracted to him but I think (as the server admin) i gave him 99999 health. I gave myself something like 500 health and I still almost died. It starts out with me getting annoyed and just shooting a nade at the ground thus sending zombies flying in all directions - that took away 200 of my health.', 'Zombie killing', 0, '', 'publish', 'closed', 'closed', '', 'zombie-killing', '', '', '2006-01-17 15:17:23', '2006-01-17 23:17:23', '', 0, 'http://www.saurdo.com/?p=4', 0, 'post', '', 0), The same code after I try and take out unwanted keys: (4, '2005-12-19 20:42:39', 'Check out this video of me killing some zombies. Eric recorded it and It's only thirty seconds long. I'm going to be mean and embed it. <center><embed SRC="http://atlas.walagata.com/w/saurdo/zombie.wmv" width="320" height="240" loop="false" volume="100%" autostart="false" ></embed> Press play</center> He added some funky music i provided and I compressed it to one megabyte so it would be painless to download. It's not very exciting but zombies are cool. I was worried they'd kill Eric because they seemed so attracted to him but I think (as the server admin) i gave him 99999 health. I gave myself something like 500 health and I still almost died. It starts out with me getting annoyed and just shooting a nade at the ground thus sending zombies flying in all directions - that took away 200 of my health.', 'Zombie killing', '0', 'publish', 'zombie-killing'), Here's my PHP code: <?php $connection = mysql_connect('', '', '') or die('can\'t connect to db'); $db = mysql_select_db('saurdo_blog', $connection) or die('can not select db'); $query = "SELECT * FROM wp_posts ORDER BY ID"; $result = mysql_query($query) or die('Query failed<br>'. mysql_error()); $n=1; while($row = mysql_fetch_array($result)){ $values .= "(".$n.", '".$row['post_date']."', '".$row['post_content']."', '".$row['post_title']."', '".$row['post_category']."', '".$row['post_status']."', '".$row['post_name']."'),"; $n++; } // for debugging //file_put_contents('test.sql', $values); die; $db2 = mysql_select_db('saurdo_site', $connection) or die('can not select db2'); $query2 = "INSERT INTO posts (`ID`, `post_date`, `post_content`, `post_title`, `post_category`, `post_status`, `post_name`) VALUES ".$values; mysql_query($query2) or die('Query2 failed<br>'. mysql_error()); ?> Is there someway I can prevent the conversion? I tried str_replace to redo it but the mysql query still failed for an unknown reason.
  6. Yeah, it seems like if you could do a foreach loop in a function then you should be able to do it without it. I guess that's not the case though. I'm looking forward to seeing your results because I haven't got a clue for a way around it. I've tried a for loop and even a do/while loop.
  7. I never liked nesting a foreach loop in a foreach loop because it seemed every time I did so it would end in a disaster. Which is what your script is doing, adding values over and over and over again. I did however put the foreach in a function and it worked. I'd like to get rid of the need for a function altogether though because this script will be going inside a function. <?php $array = array('2004', 'March', 'January', '2006', 'chips', 'June', 'February', 'April', 'May', '1994', 'hotdogs'); echo "<pre>". print_r($array, true) ."</pre>\n"; echo "Sorting...\n"; function is_month($var){ $months = array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'sepember', 'october', 'november', 'december'); foreach($months as $month){ if($month == strtolower($var)){ $p = 1;} } if($p == 1){return true;} else{return false;} } $new_array = array(); foreach($array as $key => $val){ if(is_numeric($array[$key]) || !is_month($array[$key])){ $new_array[] = $val; } else{ $month_array[strtotime($val)] = $val; } } sort($new_array); ksort($month_array); foreach($new_array as $foo){ echo "<pre>".$foo."</pre>";} echo "Months<br>"; foreach($month_array as $foo){ echo "<pre>".$foo."</pre>";} ?>
  8. Yeah, I was thinking that there had to be a better way to do it when I was writing it. I'd like to see your results. I'm always open to smaller and more efficient scripts.
  9. Okay! I put the any value that's a month in a different array so it'd be easier to deal with. <?php $array = array(2004, 'March', 'January', 2006, 'chips', 'June', 'February', 'April', 'May', 1994, 'hotdogs'); echo "<pre>". print_r($array, true) ."</pre>\n"; echo "Sorting...\n"; function is_month($var){ if(strtolower($var) == 'january' || strtolower($var) == 'february' || strtolower($var) == 'march' || strtolower($var) == 'april' || strtolower($var) == 'may' || strtolower($var) == 'june' || strtolower($var) == 'july' || strtolower($var) == 'august' || strtolower($var) == 'september' || strtolower($var) == 'october' || strtolower($var) == 'november' || strtolower($var) == 'december'){ return true;} else{ return false;} } $new_array = array(); foreach($array as $key => $val){ if(is_numeric($array[$key]) || !is_month($array[$key])){ $new_array[] = $val; } else{ $month_array[strtotime($val)] = $val; } } sort($new_array); ksort($month_array); foreach($new_array as $foo){ echo "<pre>".$foo."</pre>";} foreach($month_array as $foo){ echo "<pre>".$foo."</pre>";} ?> Thanks for the help boo_lolly!
  10. Umm, I turned that into this because the way you had it the script was just displaying the numbers. <?php $array = array('2004', 'March', 'January', '2006', 'chips', 'June', 'February', 'April', 'May', '1994', 'hotdogs'); echo "<pre>". print_r($array, true) ."</pre>\n"; echo "Sorting...\n"; $new_array = array(); foreach($array as $key => $val){ $new_array[strtotime($val)] = $val; } ksort($new_array); echo "<pre>". print_r($new_array, true) ."</pre>\n"; ?> And that returns: Array ( [0] => hotdogs [767048064] => 1994 [1169452800] => January [1172131200] => February [1174546800] => March [1177225200] => April [1177297440] => 2004 [1177297560] => 2006 [1179817200] => May [1182495600] => June ) I don't know what happened to the chips string... and I need to find a way to 2004 and 2006 display next to 1994. Perhaps in a different array. Perhaps with a function that finds if there are alphabetical characters in the string. Thanks for the strtotime function though, didn't know about that one. I just realized what happened to chips, it was replaced by hotdogs because both their keys are the same..
  11. I don't want to sort alphabetically, which is what sort does, because then It'd return: Array ( [0] => 1994 [1] => 2004 [2] => 2006 [3] => April [4] => February [5] => January [6] => June [7] => March [8] => May [9] => chips [10] => hotdogs ) I don't think the months go April, February, January, June, March, May. Unless those damn astronomers changed something again! :-\
  12. Hello! I have an array of values that I need to sort by month and year. This array may also contain values that are not months or a year. I found the function "usort" but PHP's documentation isn't very good, I don't understand how to use it, and I'm not even sure that that's the function i need to use. So, for example. // This array array('2004', 'March', 'January', '2006', 'chips', 'June', 'February', 'April', 'May', '1994', 'hotdogs'); // would turn into array('1994', '2004', '2006', 'January', 'February', 'March', 'April', 'May', 'June', 'chips', 'hotdogs'); Thanks for any help!
  13. Hello! I'm trying to make an active users script in PHP, not because I need one, because I want to know if i can. I made one that worked with PHP sessions but then it failed to work with people who had cookies turned off. So, now the script i'm using stored the time and users IP in a flat file. Needless to say it doesn't work for a seemingly unknown reason. It's a pretty small script that I heavily commented so I wouldn't get lost. If one of you more experienced PHP gurus can take a look through it real fast and tell me what's wrong and what I could do to fix it that'd be great. <?php // open file for reading and writing $handle = fopen("test.txt", "a+"); // if you can read the file (IE if it's not empty) if($contents = fread($handle, filesize("test.txt"))){ // split the different times and IP's $times = split(',', $contents); // take off last array string because it's blank array_pop($times); $none = 0; // loop through times and ip's foreach($times as $time){ // split times from IP's $split = split('-', $time); $time = $split[0]; $ip = $split[1]; // if users IP is in the contents record it if($ip == $_SERVER['REMOTE_ADDR']){ $none = 1; } } // if the users IP did not exist in the file. if($none != 1){ // write the IP address and time if(fwrite($handle, time().'-'. $_SERVER['REMOTE_ADDR'].',') == FALSE){ echo "failed to write part one";} else{ echo "wrote: ". time().'-'. $_SERVER['REMOTE_ADDR'].',';} } } // if we cannot open the file, write the IP address and time else{fwrite($handle, time().'-'. $_SERVER['REMOTE_ADDR'].',');} fclose($handle); // open file $handle = fopen("test.txt", "r+"); // if we can open the file if($contents = fread($handle, filesize("test.txt"))){ // split the different times and IP's $times = split(',', $contents); // get rid of last string array_pop($times); // loop through times and IPs foreach($times as $time){ // split times from IP's $ip = split('-', $time); $time = $ip[0]; $ip = $ip[1]; // if the time in the file is still good add it to an array if($time + 10 < time()){ $activeusers .= $time.'-'.$ip.','; echo "Time good, added user";} // if the time isn't still good but the users IP // exists in the file add them to active uers but use current time elseif($ip == $_SERVER['REMOTE_ADDR']){ $activeusers .= time().'-'.$ip.','; echo "Time expired, but added user";} } if(fwrite($handle, $activeusers) == FALSE){ echo "<br>failed to write part two<br>";} } else{echo "Failed to open file for writing second part";} echo "<br>"; echo $activeusers; ?> I've rewritten this script twice and each time it's had a different problem.
  14. Yeah, substr is definitely what i needed. It even provides a negative count so you can get the last character. substr($string, -1, 1); Thanks!
×
×
  • 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.