Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. The encoding should already be set in the XML, SimpleXML only converts XML to an object
  2. curl_exec returns the page you called!
  3. its probably memory, turn error reporting on code: error_reporting(E_ALL); why not use array_unique then filter the emails for valid emails ??
  4. lol, your very welcome
  5. the logic is the same, just change URL to yourtubURL tested in IE & FF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TITLE</title> </head> <body> <form action="" method="get"> <input name="youtubeURL" type="text" value="http://www.youtube.com?v=AkdfOsdfj" size="65" /><BR /> <input name="RUN" type="submit" value="Run IT" /> </form> <?php if(!empty($_GET['youtubeURL'])){ if (preg_match('/v=([^&]+)/i', $_GET['youtubeURL'],$match)) { echo "Found: ".$match[1]; } else { echo "No V found"; } } ?> </body> </html>
  6. as you say you know about joins I assume these results are not what your looking for so i have so say no.. personally i think your over complicating the problem,
  7. Here is a example with a form <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>TITLE</title> </head> <body> <form action="" method="get"> <input name="URL" type="text" value="http://www.youtube.com?v=AkdfOsdfj" size="65" /><BR /> <input name="RUN" type="submit" value="Run IT" /> </form> <?php if(!empty($_GET['URL'])){ if (preg_match('/v=([^&]+)/i', $_GET['URL'],$match)) { echo "Found: ".$match[1]; } else { echo "No V found"; } } ?> </body> </html> you can change the method from get to post but then your need to update the 2 $_GET to $_POST OH yeah and if you wanted your example URL to work use this code <?php if(!empty($_GET['youtubeURL'])){ if (preg_match('/v=([^&]+)/i', $_GET['youtubeURL'],$match)) { echo "Found: ".$match[1]; } else { echo "No V found"; } } ?>
  8. Check to see if magic quotes are on, they probably are, if so turn them off or strip the slashes BEFORE entering it into the database here is some portable code from php.net <?php if (get_magic_quotes_gpc()) { $lastname = stripslashes($_POST['lastname']); } else { $lastname = $_POST['lastname']; } $lastname = mysql_real_escape_string($lastname); $sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')"; ?>
  9. If your referring to this SELECT *,(SELECT name FROM galleries WHERE id=gallery_photos.id) AS gallery_name FROM gallery_photos ORDER BY gallery_id then it will probably work.. have you tried it ? however i would use a Join
  10. If your saying you want to do one query and have it create separate arrays for each set without you having to write logic yourself then the answer is no The logic is pretty simple personally i don't see a problem !
  11. Have a look at SQL JOIN, IE SELECT * FROM `Galleries` LEFT JOIN `Gallery Photos` ON `Galleries`.id=`Gallery Photos`.gallery_id WHERE `Galleries`.id = 1
  12. The "code" is fine, however we can't test your data, if you give us some sample data that should work but doesn't then we can help, however everything points to that being the problem!
  13. I think it would be a good idea to have the disable option as some people wouldn't want their users having that option, and it should be a lot of code so yeah extra anti feature won't hurt
  14. reading the code, I should of said use $sm instead of $img for the second one, as if the image is large the $sm would be smaller.. your script won't allow upper case extensions ie JPG to fix add i ie /[.](jpg)|(gif)|(png)$/i also you don't need to capture the extension if your re-checking, however you could use it instead of re-checking here is a quick clean up *untested so probably full of errors* <?php $fname = strtolower($_FILES['subimg']['name']); // grab uploaded image's filename and lowercase the extension (ex: .JPG) // verify that image uploaded is proper extension if(preg_match('/\.(jpg|gif|png)$/i', $fname, $match)) { $ext = strtoupper($match[1]); // set image variables $qty = 80; $randomappend=rand(0000,9999); // generate random number to append to filename $src = $_FILES['subimg']['tmp_name']; // grab the src for where the image is temporarily held $final_width_of_image = 600; $path_image = '../submissions/'; $filesub = $randomappend . $fname; // initiate new file name for submission's full image $target = $path_image . $filesub; // set variable for submission image's new location with appended name $final_width_of_thumb = 250; $final_height_of_thumb = 180; $path_image_thumb = '../submissions/thumbs/'; $filethumb = $randomappend . $fname; // initiate new file name for submission's thumbnail $target_thumb = $path_image_thumb . $filethumb; // set variable for thumbnail's new location with appended name move_uploaded_file($src, $target); // RESIZE TO FIT NEWS COLUMN WIDTH // CHECK FILE EXTENSION switch($ext){ case "JPG": $img = imagecreatefromjpeg($target); break; case "GIF": $img = imagecreatefromgif($target); break; case "PNG": $img = imagecreatefrompng($target); break; } // FIND UPLOADED FILE'S ORIGINAL DIMENSIONS $ox = imagesx($img); $oy = imagesy($img); // SET NEW DIMENSIONS FOR SUBMISSION IMAGE $sx = $final_width_of_image; $sy = floor($oy * ($final_width_of_image / $ox)); $sm = imagecreatetruecolor($sx, $sy); imagecopyresampled($sm, $img, 0,0,0,0,$sx,$sy,$ox,$oy); if(!file_exists($path_image)) { if(!mkdir($path_image)) { die("There was a problem."); } } imagejpeg($sm, $target, $qty); $sub .= '<br /><img src="' . $target . '" alt="submission image">'; $sub .= '<br />Submission was successfuly created!<br />'; echo $sub; // SET NEW DIMENSIONS FOR THUMBNAIL $tx = $final_width_of_thumb; $ty = $final_height_of_thumb; $tm = imagecreatetruecolor($tx, $ty); imagecopyresampled($tm, $sm, 0,0,0,0,$tx,$ty,$sx,$sy); if(!file_exists($path_image_thumb)) { if(!mkdir($path_image_thumb)) { die("There was a problem."); } } imagejpeg($tm, $target_thumb, $qty); $tn .= '<br /><img src="' . $target_thumb . '" alt="thumbnail image">'; $tn .= '<br />Thumbnail was successfuly created!<br />'; echo $tn; } ?>
  15. Please mark as solved if this is solved! (bottom left) also what do you mean by
  16. try this *untested* $url = "http://www.youtube.com/watch?v=nGawAhRjtoA&feature=topvideos"; if (preg_match('/v=([^&]+)/i', $url,$match)) { echo "Found: ".$match[1]; } else { echo "No V found"; }
  17. You're right the image has been moved already, but also the image is loaded into memory, so use that one instead this will also have memory so remove move_uploaded_file($src, $target_thumb); if(preg_match('/[.](jpg)$/', $filethumb)){ $img2 = imagecreatefromjpeg($path_image_thumb . $filethumb); } else if (preg_match('/[.](gif)$/', $filethumb)){ $img2 = imagecreatefromgif($path_image_thumb . $filethumb); } else if (preg_match('/[.](png)$/', $filethumb)){ $img2 = imagecreatefrompng($path_image_thumb . $filethumb); } and change all $img2 to $img; that should do it
  18. Sorry the delayed reply, The problem isn't as random as you think, Here is the problem: your download page has extra content, being change this to ONLY the PHP code you posted and it should be fine.. okay now the why Lets look at the last example, you uploaded "test" and it downloaded "<!DO" this is because it tried to download BUT you stated the size is 4 characters so you get if you review the other example your probably see the same pattern Hope this helps
  19. LOL@ Just do another loop of 5 ie echo '<select name="time">'; for ($d = 0; $d < 5; $d++){ $start = strtotime('12:00am'); $end = strtotime('11:45pm'); for ($i = $start; $i <= $end; $i += 900){ echo '<option>' . date('F j, Y, \a\t g:i a', $i+($d*24*60*60)); } } echo '</select>';
  20. text files should be fine, do you have some examples of input and output!
  21. MadTechie

    time

    date will work with seconds so your be better off spliting ie $date = "1057"; $newdate= preg_replace('/(\d\d)(\d\d)/im', '\1:\2', $date); echo $newdate; using a regex is overkill so substr would also work well $date = "1057"; echo substr($date, 0, 2).":".substr($date, 2, 2);
  22. whats the field type of "data", if its text then change $data = $dbLink->real_escape_string(file_get_contents($_FILES ['uploaded_file']['tmp_name'])); to $data = base64_encode(file_get_contents($_FILES ['uploaded_file']['tmp_name'])); and echo $row['data']; to echo base64_decode($row['data']); However you should use a blob type if you still have a problem, then can you give some more details
  23. check the file path $fh2 = fopen($myFile2, 'r'); if( !file_exists($myFile2) ) die("No file found");//Add this line if it fails try this instead $myFile2 = dirname(__FILE__)."/members.txt"; $theData2 = file_get_contents($myFile2); echo $theData2;
  24. Depends what the server is going to be used for, if you want a cookie free site then no, otherwise yes! if you don't store it in a cookie it will need to be passed another way, ie via the URL
  25. function array_to_table wasn't closed try this *untested* <?php $file = "music.xml"; $to_print = array("Name", "Artist", "Album", "Track ID", "Year", "Play Count", "Track Number", "Track Count", "Genre", "Rating", "Date Added"); $db_host = "localhost"; $db_name = "music_library"; $db_table = "table"; $db_username = "root"; $db_password = ""; function db_connect() { global $db_host, $db_name, $db_table, $db_username, $db_password; mysql_connect($db_host, $db_username, $db_password) or die("<p style='font-color:red'>Cannot connect to mySQL server</p>"); mysql_select_db($db_name) or die("<p style='font-color:red'>Cannot connect to mySQL database</p>"); } function alter_print_arr(&$input, $key) { $input = str_replace(' ', '_', strtolower($input)); } function array_to_table($array) { global $db_table, $to_print; db_connect(); mysql_query("DELETE FROM $db_table") or die("Could not remove old records."); mysql_query("OPTIMIZE TABLE $db_table"); foreach ($array as $elem_key => $element) { if (isset($element[track_id])) { $sql = ""; foreach ($element as $k => $v) { if (in_array($k, $to_print)) { $sql .= "$k='" . mysql_real_escape_string(str_replace('=amp=', '&', $v)) . "', "; } } $sql = rtrim(ltrim($sql, "track_id='$element[track_id]', "), ", "); $sql1 = "INSERT INTO $db_table (track_id) VALUES ('$element[track_id]');"; $sql2 = "UPDATE $db_table SET $sql WHERE track_id=$element[track_id];"; mysql_query($sql1) or die(mysql_error()); // echo"$sql1<br />$sql2<br /><br />"; // For debugging. Uncomment with caution! mysql_query($sql2) or die(mysql_error()); } } } function start_element($parser, $name, $attribs) { global $current_element, $number_dicts; if ($name == "DICT") { $number_dicts++; } if ($number_dicts > 2) { $current_element = $name; } } function end_element($parser, $name) { global $songs, $current_element, $current_data, $number_dicts, $array_key, $end_of_songs; if ($end_of_songs) { return; } if ($current_element == "KEY") { $array_key = str_replace(' ', '_', strtolower($current_data)); } else { $songs[$number_dicts][$array_key] = $current_data; } } function character_data($parser, $data) { global $number_dicts, $current_data, $end_of_songs; if ($data == "Playlists") { $end_of_songs = true; } $current_data = trim($data); } array_walk($to_print, 'alter_print_arr'); // print_r($array); // For debugging. Uncomment with caution! } $xml_parser = ""; //will hold each song in a 2-d array $songs = array(); //counter, number of 'dict' elements encountered $current_key=""; $number_dicts = 0; //key for each element in second dimension of array $current_element=""; //stores xml element name //value for second dimension array elements $current_data = ""; //boolean used to help let us know if we're done with the song list $end_of_songs = false; $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1); xml_set_element_handler($xml_parser, "start_element", "end_element"); xml_set_character_data_handler($xml_parser, "character_data"); if (!($fp = @fopen($file, "r"))) { return false; } while ($data = fread($fp, 4096)) { // xml_parser jumps over ampersands. Decode any entities then replace any ampersands. // Reverse this when building SQL statement. if (!xml_parse($xml_parser, str_replace('&', '=amp=', html_entity_decode($data)), feof($fp))) { die(sprintf("XML error: %s at line %d ", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); array_to_table($songs); echo "Done! "; ?>
×
×
  • 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.