Hi all,
I'm new of this forum and php language.
Now, I ask the forum mind to help me because I do not know to develop this.
I have this script: SELECT+WHILE+Table RESULTS. In the Table Of results there is a script to view if url (getup from SELECT) is enable or in http error. But when run this script, obtain a display error: Cannot redeclare a checkurl function and the script displayng only the first and second record in the table and on the second, display a error.
How do this?
This is the script:
<?php
include("connect.php");
$result = mysql_query("
SELECT field1,
filed2,
filed3,
filed4,
field5
FROM table
");
$rows=mysql_num_rows($result);
?>
<?php
$i=0;
while ($i < $rows) {
$field1=mysql_result($result,$i,"field1");
$field2=mysql_result($result,$i,"field2");
$field3=mysql_result($result,$i,"field3");
$field4=mysql_result($result,$i,"field4");
$field5=mysql_result($result,$i,"field5");
?>
<td ><?php echo $field1; ?></td>
<td ><?php echo $field2; ?></td>
<td ><?php echo $field3; ?></td>
<td ><?php echo $field4; ?></td>
<td ><?php echo $field5; ?></td>
<?php
function checkurl($url){
$headers = get_headers("$url");
if(preg_match('#^HTTP/.*\s+[200]+\s#i', $headers[0])==1){
echo $url." server funzionante";
}elseif(preg_match('#^HTTP/.*\s+[301]+\s#i', $headers[0])==1){
echo $url." error 301";
}elseif(preg_match('#^HTTP/.*\s+[404]+\s#i', $headers[0])==1){
echo $url." error 404";
}else{
echo $url." default error";
}
echo "<br />";
}
$url_uno = $field5;
checkurl("$url_uno");
?>
</td>
<?php
$i++;
}
?>
Thanks