<?php
$thesite = strip_tags($_GET['s']);
$original_file = @file_get_contents($thesite);
if ($original_file === false) {
die("$thesite does not exist");
} elseif($orginial_file === true ) {
$data = $path_info['host'];
$check = mysql_query("SELECT * FROM first WHERE name='$data'");
} else {
//step3
}
I want to check the DB for $data
. If it exists, move on to the next step; if not, do step 3
<?php
$thesite = strip_tags($_GET['s']);
$original_file = @file_get_contents($thesite);
if ($original_file === false) {
die("$thesite does not exist");
} elseif($orginial_file === true ) {
$data = $path_info['host'];
$check = mysql_query("SELECT * FROM first WHERE name='$data'");
#exist = mysql_num_rows($check);
if ($exist) {
// next step
}
else {
// step 3
}
}
Check the value of mysql_num_rows
after running the query. If it's 0
, there were no rows with name
equal to $data
.
By the way, you shouldn't be inserting $data
directly into your query, otherwise you're open to SQL injection. Here's a better way:
mysql_query("SELECT * FROM first WHERE name='".mysql_real_escape_string($data)."'");
Also, file_get_contents
will not return true
if it succeeds. It will return the contents of the file as a string.