Monday, 15 March 2010

php - Function in for () loop: Fatal error: Cannot redeclare -



php - Function in for () loop: Fatal error: Cannot redeclare -

i have this code, when seek execute it, gives next error: fatal error: cannot redeclare genereerlivecodep() (previously declared in livestream.php:33) in livestream.php on line 32.

session_start(); mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); //header("location: index.php"); if($_session['***'] == '***'){ $fp = fopen("test.html", 'w'); fwrite($fp, ""); fwrite($fp, '<p class="green">*** online</p>'); $result = mysql_query("select count(1) ***"); $row = mysql_fetch_array($result); $rows = $row[0]+1000; echo "rows: ".$rows."\n"; ($id = 1000; $id < $rows; $id++) { echo "id: ".$id."\n"; function genereerlivecodep () { $lengthcode = 6; $characters = '1234567890abcdefghijklmnopqrstuvwxyz'; $livecodefunction = ''; ($p = 0; $p < $lengthcode; $p++) { $livecodefunction .= $characters[mt_rand(0, strlen($characters))]; } homecoming $livecodefunction; } $livecode = genereerlivecodep (); echo "livecode: ".$livecode."\n"; $x = mysql_query("update *** set livecode='".$livecode."' *** = '".$***."'"); echo $x."\n"; } }

what should do?

you forgot close for loop before declaring function. code should this:

... ($id = 1000; $id < $rows; $id++) { echo "id: ".$id."\n"; } function genereerlivecodep () { ...

php function for-loop fatal-error

No comments:

Post a Comment