Page 1 of 1

error with array item

Posted: Mon Apr 19, 2004 9:13 am
by tiresome

Code: Select all

<?php

mysql_select_db('test');

  $entryid[] = $HTTP_POST_VARS['entry_id[]'];

  while (list($key, $value) = each($entryid)) {
    if ( !empty( $value)) {
      print "<li>Deleting entry #$value\n";
      $query = "delete from guestBook where entry_id = $value";

      $result = mysql_query($query);


?>
the php document below submits the data to the php document but there is an error in line 3 of the above php cod($entry[]...)


Code: Select all

<?php
 echo '</td>';
     echo '<td>';
     print '<input type="checkbox" name="entry_id[]" value=';
     print $row['entry_id'];
     print '> Yes, delete entry #';
     print $row['entry_id'];[/url]
?>
Since entry id is an array shouldn't i post it as an array item or should i just post it as a variable without the square brackets at the end?[/php_man]

Posted: Mon Apr 19, 2004 9:14 am
by tiresome
Sorry I meant to say the php doc below submits the data to the php document above ie. they are both separate files.

I am sure you guys figured that out but thought I'd clarify it anyway :)

Posted: Mon Apr 19, 2004 9:21 am
by magicrobotmonkey
Whats the error? and trying doing a print_r($HTTP_POST_VARS['entry_id[]']) to see just what that guys full of!

note: $HTTP_POST_VARS is old! Use $_POST

Posted: Mon Apr 19, 2004 9:34 am
by tiresome
Oh, it's working fine now. I just had to removie all the square brackets from the line below

$entryid[] = $HTTP_POST_VARS['entry_id[]'];

Strange! It works though. I thought entryid was an array. Anyway, I probably have no idea what I am talking about hehe :?