Hi there, I'm installing this script on a php5 server, and it dosn't seem to be working. So I was wondering if anyone could take a look at the script below and let me know if they think there's anything wrong with it. The main problem is that the script doesn't seem to be updating when I submit the script. So there may be something wrong with the "if($_POST['update']) {" part? The problem isn't within the page head.php <?php include_once("head.php"); if($_POST['update']) { foreach ($_POST['c_code'] as $key => $value) { mysql_query("UPDATE locDest SET destination = '$destination[$key]' WHERE c_code = '$value' ") or die("Error: " . mysql_error()); } } ?> <html> <head> <title>Update List</title> <link href="ip.css" rel="stylesheet" type="text/css"> </head> <body> <form name="form1" method="post" action="<?php echo $_SYSTEM['PHP_SELF']; ?>"> <table width="650" border="1" align="center" cellpadding="3" cellspacing="3" bordercolor="#000000"> <tr> <td align=center class="bodyBold"><b>Country</b></td> <td width="10" align=center class="bodyBold"><strong>Code</strong></td> <td align=center class="bodyBold"><b>Send traffic to</b></td> </tr> <?php $query = "SELECT * from locDest ORDER BY country"; $result = mysql_query ($query) or die ("Query failed"); while ($r = mysql_fetch_array($result)) { extract($r); echo <<<END <tr> <td><font class=body>$country</font></td> <td align=center class=body>$c_code</font></td> <td><input name="destination[]" type="text" value="$destination" size="45"></td> <input name="c_code[]" type="hidden" value="$c_code"> </tr> END; } ?> </table> <table width="650" border="0" align="center" cellpadding="4"> <tr> <td align=left width="57%"> </td> <td align=right width="43%"><input name="update" type="submit" id="update" value="Submit"></td> </tr> </table> </form> </body> </html> PHP: Thanks a lot
Can anyone see anything wrong with this? <?php include_once("head.php"); if($_POST['update']) { foreach ($_POST['c_code'] as $key => $value) { mysql_query("UPDATE locDest SET destination = '$destination[$key]' WHERE c_code = '$value' ") or die("Error: " . mysql_error()); } } ?> PHP:
What is $destination? I think it should be $_POST['destination'][$key] <?php include_once("head.php"); if($_POST['update']) { foreach ($_POST['c_code'] as $key => $value) { mysql_query("UPDATE locDest SET destination = '".$_POST['destination'][$key]."' WHERE c_code = '$value' ") or die("Error: " . mysql_error()); } } ?> PHP: