bumba000 Posted August 21, 2008 Share Posted August 21, 2008 Hi All, I have a connection to my db finally. I use $dbResults = mysql_query("SELECT website_url2 FROM url", $connection); if(!$dbResults) { die("Database Table Selection Failed: " . mysql_error()); } while ($row = mysql_fetch_array($dbResults)) { echo $row[0].', '; } To see all of my results in my browser just like the tutorials say. It works! Great! Now I need to use those results as a list of urls with the following code kinda like a foreach. $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Uncomment this for Windows. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $websites); $result = curl_exec($ch); echo '<pre>'; //print_r(curl_getinfo($ch)); echo '</pre>'; echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '<br><br>'; if (curl_errno($ch) == 0) {echo 'Good SSL';} else { echo 'bad ssl:'.$websites;} //$_POST['$websites']; //$badSiteMessage = "This website currently has a broken or no SSL:\r\n" . $websites; //mail($myaddress, 'Automated Bad SSL Scan Report', $badSiteMessage);} //echo $ch; curl_close ($ch); echo '<br>'.'EOF'; So instead of the while loop that I have there I need to know how to get my results into a variable named $websites in a usable fashion. I have been beating my head against this wall for almost 24 hours. Please help me. I'm just not sure how much longer I can keep this up. $myName = "John"; Thanks in Advance, echo $myName; Quote Link to comment Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 <?php if ($dbResults = mysql_query("SELECT website_url2 FROM url", $connection)) { if (mysql_num_rows($dbResults)) { while ($row = mysql_fetch_assoc($dbResults)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $row['website_url2']); if ($result = curl_exec($ch)) { if (curl_errno($ch) == 0) { echo 'Good SSL'; } else { echo 'bad ssl:' . $row['website_url2']; } } else { echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '<br><br>'; } curl_close ($ch); echo '<br>'.'EOF'; } } else { die("Database Table Selection Failed: " . mysql_error()); } } else { echo "query failed"; } ?> Quote Link to comment Share on other sites More sharing options...
bumba000 Posted August 21, 2008 Author Share Posted August 21, 2008 Thank you soooo much for your quick reply. Yeah it will prolly be a few months more before I can just come up with something like that. I did alter it slightly but I still get no "bad ssl" for a known bad ssl url that I have in my db. I have 3 urls in the db. 2 are good 1 is bad. The results that I get in the broswer are Good SSL EOF Good SSL EOF if ($dbResults = mysql_query("SELECT website_url2 FROM url", $connection)) { if (mysql_num_rows($dbResults)) { while ($row = mysql_fetch_assoc($dbResults)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $row['website_url2']); if ($result = curl_exec($ch)) { if (curl_errno($ch) == 0) { echo 'Good SSL'; } else { echo 'bad ssl:' . $row['website_url2']; } curl_close ($ch); echo '<br>'.'EOF'.'<br>'; } } } } ?> Please advise. Thanks again, John Quote Link to comment Share on other sites More sharing options...
bumba000 Posted August 21, 2008 Author Share Posted August 21, 2008 I think I need a switch here. I'm on my way! Quote Link to comment Share on other sites More sharing options...
bumba000 Posted August 21, 2008 Author Share Posted August 21, 2008 That does not appear to be the answer. WOW. This is worse than spanish! I need to see two things here in my browser. Good SSL and Bad SSL. For those that are good show Good SSL and for those that aren't good show Bad SSL. Why is this so complicated? If I wanted to go to the nearest city and take a php course which class would I ask for? Thanks, John Quote Link to comment Share on other sites More sharing options...
trq Posted August 21, 2008 Share Posted August 21, 2008 You might try.... <?php if ($dbResults = mysql_query("SELECT website_url2 FROM url", $connection)) { if (mysql_num_rows($dbResults)) { while ($row = mysql_fetch_assoc($dbResults)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $row['website_url2']); if (curl_errno($ch) == 0) { echo 'Good SSL'; } else { echo 'Bad SSL:'; } curl_close ($ch); echo '<br />'; } } else { die("query found no results"; } } else { echo "query failed" . mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
bumba000 Posted August 21, 2008 Author Share Posted August 21, 2008 This give me Parse error: syntax error, unexpected ';' in /home/hackerse/public_html/sslTest4.php on line 33 which is : die("query found no results"; No way that I alter this makes the browser happy. Also. How will this make the good and the bad ssl urls show up in the browser. Basically in the end what I would like to do is if it's good (curl_errno ==0) I see Good SSL if (curl_errno > 1) I see Bad SSL. Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted August 21, 2008 Share Posted August 21, 2008 Close the ). die("query found no results"); Quote Link to comment Share on other sites More sharing options...
bumba000 Posted August 21, 2008 Author Share Posted August 21, 2008 I did that . It then gives an unexpected ")" Parse error: syntax error, unexpected ')', expecting ',' or ';' in /home/hackerse/public_html/sslTest4.php on line 36 Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted August 21, 2008 Share Posted August 21, 2008 try this: die("query found no results"); } } else { echo "query failed" . (mysql_error()); } Quote Link to comment Share on other sites More sharing options...
bumba000 Posted August 21, 2008 Author Share Posted August 21, 2008 Thank you all for your help on this. In the end it was a little from each and my goofy way of hijacking php. $myQuery = mysql_query("SELECT website_url2 FROM url", $connection); if(!$myQuery) { die("Database table Selection Failed: " . mysql_error()); } while ($row = mysql_fetch_assoc($myQuery)) { //Filename: curl_test.php $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Uncomment this for Windows. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $row['website_url2']); $result = curl_exec($ch); if (curl_errno($ch) == 0){ echo 'Good SSL '.$row['website_url2']; } else { echo 'bad ssl: '.$row['website_url2']; } curl_close ($ch); echo '<br>'.'EOF'.'<br>'; } ?> This gives me the result Good SSL https://www.domain1.com EOF bad ssl: https://www.domain2.com EOF Good SSL https://www.domain3.com EOF Once again, Thank you so much for your time and consideration with this super newb. Best Regards, John Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted August 21, 2008 Share Posted August 21, 2008 you are welcome!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.