Jump to content

jjmusicpro

Members
  • Posts

    290
  • Joined

  • Last visited

    Never

Everything posted by jjmusicpro

  1. i am trying to loop through results in my db, however, i cant get it to work. i need the echo to ouput something with " in it... <?php //Begin of Checking Loop $URLarray = array( parse_str("$QUERY_STRING"); $db = mysql_connect("localhost", "url_tester_user","xxxxx") or die("Could not connect."); if(!$db) die("no db"); if(!mysql_select_db("url_tester_db",$db)) die("No database selected."); $acc1="SELECT add_url from urls"; $acc2=mysql_query($acc1) or die("Could not select accounts."); while($acc3=mysql_fetch_array($acc2)) { echo " "\$acc3[add_url]\";"; } // need to be formatted likt this -- >"http://testplace.com/", "http://myspace.com/" ); echo "<table border=1>\n";
  2. is there a way to limit the 000000 or the percision on microtime()? right now it will say 1.254112111 is there a way i can make it display only say 1.253? foreach($URLarray as $K => $URL) { $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; if( url_exists($URL) ) { $data = file_get_contents($URL); unset($data);//dump the data $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); $UrlResults[$URL] = array("Access" => true, "Time"=>$totaltime); echo " <script language='javascript'>display('$K', '$totaltime seconds');</script>"; }else{ $UrlResults[$URL] = array("Access" => false); echo " <script language='javascript'>display('$K', 'Failed');</script>"; } ob_flush(); flush(); }
  3. i try to run the script with multiple sites to check but it just comes up blank... http://neckter.com/linkchecker.php <head><title>Test Cheker 1.0v</title></head> <body> <b>Test Urls 1.0v</b><p> <?php $URLarray = array( "http://www.phpfreaks.com/" ); "http://www.ebay.com/" ); "http://www.myspace.com/" ); echo "<table>\n"; echo " <tr>\n"; echo " <td>\n"; echo "URL"; echo " </td>\n"; echo " <td>\n"; echo "Time"; echo " </td>\n"; echo " </tr>\n"; foreach($URLarray as $URL) { echo " <tr>\n"; $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; if( url_exists($URL) ) { $data = file_get_contents($URL); unset($data);//dump $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); $UrlResults[$URL] = array("Access" => true, "Time"=>$totaltime); echo " <td>\n"; echo "$URL"; echo " </td>\n"; echo " <td>\n"; echo "$totaltime seconds."; echo " </td>\n"; }else{ $UrlResults[$URL] = array("Access" => false); echo " <td>\n"; echo "$URL"; echo " </td>\n"; echo " <td>\n"; echo "Failed"; echo " </td>\n"; } echo " </tr>\n"; flush(); } echo "</table>\n"; //Results from loop (if you want) //foreach($UrlResults as $URLs => $Tests) //{ // echo "$URLs: "; // if($Tests['Access']) // { // echo "Works access time:".$Tests['Time']; // }else{ // echo "Failed"; // } // echo "<br />"; //} function url_exists($strURL) { $resURL = curl_init(); curl_setopt($resURL, CURLOPT_URL, $strURL); curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1); curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'readHeader'); curl_setopt($resURL, CURLOPT_FAILONERROR, 1); curl_setopt($resURL, CURLOPT_TIMEOUT, 1); $x = curl_exec($resURL); $intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE); curl_close ($resURL); if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode != 304) { return false; }else{ return true ; } } function readHeader($data) { return $data; } ?> </body>
  4. Is there a way to list the URL's first, then as i go through them, put "OK" if they load within 3 seconds, and then display time? If i have like 30 urls, the page takes forever to load, i was thinking show the URLS as they are getting done ??
  5. perfect, looks like it works... now how to i pull those values out of the db? lol
  6. Whats the command again to check if i have curl running?
  7. I only put to check phpfreaks.com for now... let me run this and see what happens.... thanks again~!
  8. When i run the script, it just keeps going and going, never stops lol... <head>Test Cheker 1.0v</head> <body> <?php $URLarray = array( "http://www.phpfreaks.com/" ); echo "<table>\n"; echo " <tr>\n"; echo " <td>\n"; echo "URL"; echo " </td>\n"; echo " <td>\n"; echo "Time"; echo " </td>\n"; echo " </tr>\n"; foreach($URLarray as $URL) { echo " <tr>\n"; $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; if( url_exists($URL) ) { $data = file_get_contents($URL); unset($data);//dump $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); $UrlResults[$URL] = array("Access" => true, "Time"=>$totaltime); echo " <td>\n"; echo "$URL"; echo " </td>\n"; echo " <td>\n"; echo "$totaltime seconds."; echo " </td>\n"; }else{ $UrlResults[$URL] = array("Access" => false); echo " <td>\n"; echo "$URL"; echo " </td>\n"; echo " <td>\n"; echo "Failed"; echo " </td>\n"; } echo " </tr>\n"; flush(); } echo "</table>\n"; //Results from loop (if you want) //foreach($UrlResults as $URLs => $Tests) //{ // echo "$URLs: "; // if($Tests['Access']) // { // echo "Works access time:".$Tests['Time']; // }else{ // echo "Failed"; // } // echo "<br />"; //} function url_exists($strURL) { $resURL = curl_init(); curl_setopt($resURL, CURLOPT_URL, $strURL); curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1); curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'readHeader'); curl_setopt($resURL, CURLOPT_FAILONERROR, 1); $x = curl_exec($resURL); $intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE); curl_close ($resURL); if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode != 304) { return false; }else{ return true ; } } function readHeader($data) { return $data; } ?> </body>
  9. Thanks MadTechie! I tried running it, however it just sits there and thinks.... Is there a way to...if the site does not load within 8 seconds then count it as a 404 error? Alos, is there a way for this to display the results as it does them? Thanks again...
  10. I PM bluesky because i think this is a super tuff php thing to do, so i was going to give him a few bucks in paypal to help me get started.
  11. Ok, so i looked around and didnt find anything on this, so here i am! I have a table named activeurls, with 2 colums, url_id and url. I have around 300 records of urls... examples of these would be www.joesplace.com/someplace.html etc.. I wanted to know how to run a script that will check the url to see if the page loads, or times out etc. plus the time it took to respond. These can just be kicked out on the same page... I dont know where to start.... Here is what i have, i dont know how to run each url through the loop, and get the time it took for it to load the page. For now, i will only care about the pages not repsonding, or broken links for error codes. ANy ideas? <head></head> <body> <form method="post"> Check Url Status:<br> <input type="submit" name="submit"> </form> <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $query = "SELECT * from activeurls"; $result2 = mysql_query($query); if($count==""){ echo "Done checking"; }else{ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $url_id = $row['url_id']; $url = $row['url']; echo "URLID . $url_id . $url"; } ?> </body>
  12. are you talking about googles api map? if so simple, you can pass the address as to googles api and it will decode it for you.
  13. I wanted to take the zipcode_entered_searched thats being passed in the URL, and put that into the query, and kick out the results, by i cant get my syntax right <?php $zipcode = $_GET['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); echo "<p><b>Make sure you contact the office in your territory!</b><br /><br><table width=\"400\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" valign=\"top\">"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo '<tr><td colspan=2 valign="middle">' . $row['company_name'] . '<br>' .$row['notes_1'] . '</b></td></tr><tr><td valign=top><img src=mm_smaller.gif></td><td>' .'<b>Phone:</b>'. ' ' . $row['phone_number'] . '<br>'.'<a href="'. $row['redirect_url'] . '"> Visit Website </a>'. ' ' .'</td></tr>'; }echo '</table>'; } ?>
  14. i just want to get thsi script here to kick out the results that match the zipcode entered i just need it to kick out this when it goes to the page, but cant seem to get rid of all those else if's }else{ echo "<p><b>Make sure you contact the office in your territory!</b><br /><br><table width=\"400\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" valign=\"top\">"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo '<tr><td colspan=2 valign="middle">' . $row['company_name'] . '<br>' .$row['notes_1'] . '</b></td></tr><tr><td valign=top><img src=mm_smaller.gif></td><td>' .'<b>Phone:</b>'. ' ' . $row['phone_number'] . '<br>'.'<a href="'. $row['redirect_url'] . '"> Visit Website </a>'. ' ' .'</td></tr>'; }echo '</table>'; <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=nf.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; }else if($count=="1"){ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $site = $row['redirect_url'] ; echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$site\">"; } }else{ echo "<p><b>Make sure you contact the office in your territory!</b><br /><br><table width=\"400\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\" valign=\"top\">"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo '<tr><td colspan=2 valign="middle">' . $row['company_name'] . '<br>' .$row['notes_1'] . '</b></td></tr><tr><td valign=top><img src=mm_smaller.gif></td><td>' .'<b>Phone:</b>'. ' ' . $row['phone_number'] . '<br>'.'<a href="'. $row['redirect_url'] . '"> Visit Website </a>'. ' ' .'</td></tr>'; }echo '</table>'; } }else{ } ?>
  15. yep the one above works but when i try to add in the headers() part, it dosent work. just blank page
  16. if i change any of those lines to the header function like you said, i get a blank page <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $groupname = $row['groupname'] ; } }else{ require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $groupname = $row['groupname'] ; } } ?> <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=nf.php\">"; exit; }else if($count=="1"){ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $site = $row['redirect_url'] ; echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$site\">"; } }else{ echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=shared.php\">"; } }else{ } ?>
  17. yep... still blank page... this is my old code, all works fine, but want it to be faster with the header() calls... <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $groupname = $row['groupname'] ; } }else{ require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $groupname = $row['groupname'] ; } } ?> <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=nf.php\">"; exit; }else if($count=="1"){ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $site = $row['redirect_url'] ; echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=$site\">"; } }else{ echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=shared.php\">"; } }else{ } ?>
  18. still blank page here is the form sending data to process.php <TD width="64%" height="47"><form action="process.php?groupid=<?php $groupid_sent = $_GET['groupid']; echo $groupid_sent ?>" method="POST"> <div align="center"> <input type="text" maxlength="10" class="searchBox" name="zipcode_entered_search" size="8" /> <input name="Submit" type="image" id="Submit" src="handyman_files/go_button.gif" alt="Request Service from your local Mr. Handyman!"> </div> </form></TD> here is complete process.php <?php ini_set('error_reporting', PHP_INI_ALL); ?> <?php require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $groupname = $row['groupname'] ; if($_SERVER['REQUEST_METHOD'] == "POST") { $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = mysql_query($query) or die(mysql_error()); $count = mysql_num_rows($result); if($count=="0"){ header( "location: nf.php?groupid=" . $_GET['groupid'] . "?zipcode_entered_search=" . $_GET['zipcode_entered_search'] ."\">"); exit; } else if($count=="1") { $row = mysql_fetch_array($result, MYSQL_ASSOC); $site = $row['redirect_url'] ; header("location:$site"); exit; } else { $row = mysql_fetch_array($result, MYSQL_ASSOC); header( "location: shared.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"); exit; } } else { // No POST, so do whatever we do if there is no POST. } ?>
  19. still a blank page when i put that at the top <?php ini_set('error_reporting', PHP_INI_ALL); ?> <?php require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $groupname = $row['groupname'] ; if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=nf.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; } else if($count=="1") { while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $site = $row['redirect_url'] ; header("location:$site"); } } else { while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=shared.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; }; } } else {} ?>
  20. ALl the process page should do is 3 things 1. if there is 0 results, go to page nf.php 2. if there is only 1 result, go to the url from db 3. if there is more then 1 result go to shared.php all that is happening is when i POST to process.php its a blank page. cant get it to work <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=nf.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; }else if($count=="1"){ $site = $row['redirect_url'] ; echo("location:$site"); exit; }else{ echo "<meta http-equiv=\"Refresh\" content=\"0;url=shared.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; }}else{}?>
  21. dont know whats going on now, it was working, now it wont work, i didnt change anything.... . <?php require_once ('connect.php'); require_once ('opendb.php'); $groupid_sent = $_GET['groupid']; $query = "SELECT * FROM metrogroups WHERE groupid='$groupid_sent'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $groupname = $row['groupname'] ; ?> <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=nf.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; }else if($count=="1"){ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $site = $row['redirect_url'] ; header("location:$site"); }}else{ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=shared.php?groupid=" . $_GET['groupid'] . '?zipcode_entered_search=' . $_GET['zipcode_entered_search'] ."\">"; };}}else{}?>
  22. everytime i try to use that header() function the page comes up blank. <?php if($_SERVER['REQUEST_METHOD'] == "POST"){ $zipcode = $_POST['zipcode_entered_search']; $query2 = "INSERT INTO zipcodes_searched (zipcode,time_date) VALUES ('$zipcode', NOW())"; $result2 = mysql_query($query2); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode' and on_off=1"; $result = @mysql_query ($query); $count = mysql_num_rows($result); if($count=="0"){ echo "<meta http-equiv=\"Refresh\" content=\"0;url=nf.php?groupid=" . $groupid_sent . $_GET['zipcode_entered_search'] ."\">"; }else if($count=="1"){ $row = mysql_fetch_array($result, MYSQL_ASSOC); $site = $row['redirect_url'] ; header("location:$site"); exit; }else{ echo "<meta http-equiv=\"Refresh\" content=\"0;url=shared.php?groupid=" . $groupid_sent . $_GET['zipcode_entered_search'] ."\">";} } } ?>
×
×
  • 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.