rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 hmmm... I see what you mean I need to review the whole script... Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 ok change this too  <td width="172"><input type="text" name="trackno_<?php echo $row['OrderNo];?>" value="<?php echo htmlspecialchars($row['Trackno']);?>" /></td>  and your code too function fnGetTrackNum($arrPost) {  $arrReturn = array();  foreach ($arrPost as $strKey => $strValue)  {    if (preg_match("/^trackno_/",$strKey)    {         $arrReturn[preg_replace("/^trackno_/","",$strKey)] = $strValue;    }  } return $arrReturn } $arrTrackNo = fnGetTrackNum($_POST); foreach($arrTrackNo as $OrderNo => $text){  $text = mysql_real_escape_string(trim($text));  $sql = "UPDATE $tbl1 SET Trackno = '{$text}' WHERE OrderNo= '{$OrderNo}'";  mysql_query($sql) or die("Failed on order {$OrderNo}"); } Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 Thanks for yuor help but im getting another   Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\xampp\htdocs\Admin_files\Unprocessed.php on line 223   Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 Sorry that was my mistake again forgot the single quote should be <td width="172"><input type="text" name="trackno_<?php echo $row['OrderNo'];?>" value="<?php echo htmlspecialchars($row['Trackno']);?>" /></td> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 Getting closer!  But getting an error on processed.php  Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\Admin_files\processed.php on line 8   Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 ok the function should of been... lol made loads of errors in the syntax because i was not actually testing the code... Â function fnGetTrackNum($arrPost) { Â $arrReturn = array(); Â foreach ($arrPost as $strKey => $strValue) Â { Â Â Â if (preg_match("/^trackno_/",$strKey)) Â Â Â { Â Â Â Â Â Â Â Â $arrReturn[preg_replace("/^trackno_/","",$strKey)] = $strValue; Â Â Â } Â } return $arrReturn; } Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 No problem you help is REALLY apricated!  Getting the error  Failed on order 9695959 Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 there must be a mysql error change  mysql_query($sql) or die("Failed on order {$OrderNo}");  to  mysql_query($sql) or die("Failed on order {$OrderNo}<BR>mysql Error:".mysql_error()."<BR>Sql:".$sql);  and tell me what error you get Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 Failed on order 9695959 mysql Error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET Trackno = 'KKKK' WHERE OrderNo= '9695959'' at line 1 Sql:UPDATE SET Trackno = 'KKKK' WHERE OrderNo= '9695959' Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 seeing the error it seems the $tbl1 table variable is null however I saw it defined in your script can you double check if its defined paste your whole script again... Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 The default for the Trackno is Null  -- ---------------------------- -- Table structure for admin -- ---------------------------- CREATE TABLE `admin` (  `OrderNo` decimal(8,0) default NULL,  `Orderdate` date default NULL,  `Custname` char(10) collate latin1_general_ci default NULL,  `Dispatchdate` date default NULL,  `Trackno` decimal(8,0) default NULL,  `Amount` decimal(5,0) default NULL,  `Shippingmet` char(255) collate latin1_general_ci default NULL,  `Ordercompleted` decimal(10,0) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;  -- ----------------------------   Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 The form for unprocessed.php is  <form action = "processed.php" method="post"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data include('adminconnect.php'); $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Ordercompleted = 0"); while( $row = mysql_fetch_array($sql) ) { // loop through and display ?> <tr align="left"> <td width="33"> </td> <td><input type = "checkbox" name="order[<?php echo $row['OrderNo'];?>]" value="checked"></td> <td width="33"> </td> <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td> <td width="61" align="center"><?php echo $row['Orderdate'];?></td> <td width="230" align="Left"><?php echo $row['Custname'];?></td> <td width="172"><input type="text" name="trackno_<?php echo $row['OrderNo'];?>" value="<?php echo htmlspecialchars($row['Trackno']);?>" /></td> <td width="56" align="right"><?php echo $row['Amount'];?></td> <td width="21"> </td> <td width="136" align="center"><?php echo $row['Shippingmet'];?></td> </tr> <? } ?> </table>   <!-- data finish -->                 <!-- -->     <div id="btn">      <input type="submit" value="Process">     </div>     <div class="clr">      <!-- -->     </div>     <div class="padTop16">      <!-- -->     </div>     <div class="clr">      <!-- -->     </div>     <!-- btn finish -->    <div class="clr">     <!-- -->    </div>    <!-- data content finish -->    </form>  Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 what about process.php Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 <?php include('adminconnect.php'); function fnGetTrackNum($arrPost) { Â $arrReturn = array(); Â foreach ($arrPost as $strKey => $strValue) Â { Â Â Â if (preg_match("/^trackno_/",$strKey)) Â Â Â { Â Â Â Â Â Â Â Â $arrReturn[preg_replace("/^trackno_/","",$strKey)] = $strValue; Â Â Â } Â } return $arrReturn; } $arrTrackNo = fnGetTrackNum($_POST); foreach($arrTrackNo as $OrderNo => $text){ Â $text = mysql_real_escape_string(trim($text)); Â $sql = "UPDATE $tbl1 SET Trackno = '{$text}' WHERE OrderNo= '{$OrderNo}'"; Â mysql_query($sql) or die("Failed on order {$OrderNo}<BR>mysql Error:".mysql_error()."<BR>Sql:".$sql); } ?> Â Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 got it change  <?php include('adminconnect.php');  too  <?php include('adminconnect.php'); $tbl1 = "admin";  and it should work!   Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 That seems to put 0 in all Tracno fields as opposed to the user input Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 your track number is decimal format in the database are you entering alphabets ? only enter digits Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 Ah ok, thanks  The only problem left is getting the 1 to post into the Orderscompleted field Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 this  "UPDATE $tbl1 SET Trackno = '{$text}' WHERE OrderNo= '{$OrderNo}'";  should be  "UPDATE $tbl1 SET Ordercompleted='1',Trackno = '{$text}' WHERE OrderNo= '{$OrderNo}'"; Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 Thats turned ALL the Orderscompleted to 1 Quote Link to comment Share on other sites More sharing options...
adam291086 Posted January 29, 2008 Share Posted January 29, 2008 that means that there is a problem with  $OrderNo.  Echo it out to see that the value is. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 change  <td><input type = "checkbox" name="order[<?php echo $row['OrderNo'];?>]" value="checked"></td>  to  <td><input type = "checkbox" name="order[]" value="<?php echo $row['OrderNo'];?>"></td>  change  foreach($arrTrackNo as $OrderNo => $text){  $text = mysql_real_escape_string(trim($text));  $sql = "UPDATE $tbl1 SET Trackno = '{$text}' WHERE OrderNo= '{$OrderNo}'";  mysql_query($sql) or die("Failed on order {$OrderNo}<BR>mysql Error:".mysql_error()."<BR>Sql:".$sql); }  to  foreach ($_POST['order'] as $strKey => $strValue) {  $text = mysql_real_escape_string(trim($arrTrackNo[$strValue]));  $sql = "UPDATE $tbl1 SET Ordercompleted='1',Trackno = '{$text}' WHERE OrderNo= '{$strValue}'";  mysql_query($sql) or die("Failed on order {$OrderNo}<BR>mysql Error:".mysql_error()."<BR>Sql:".$sql); }  and your done.... Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 I updated the code but it still just puts 1 in all the Ordercompleted Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 29, 2008 Share Posted January 29, 2008 hmm.. it will only mark the orders complete which you checked... did you check all the orders... Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted January 29, 2008 Author Share Posted January 29, 2008 No just checked 1 order 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.