#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    16
    Rep Power
    0

    $_POST strange chars after passing


    Selected data from a table and loading it into an array then sending the ID field to another PHP.
    The echo of the id works fine and displays 1 (first record in the table). But when it is passed to update_programs_clients.php and echo'd it shows 1/'

    Not sure where the /' is coming from.

    Here is the while loop in the first php:
    PHP Code:
    while ($row mysqli_fetch_array($result))
          {
          
    $current_id=$row['id'];
          echo 
    $current_id;
         echo 
    "<form method='post'   action='update_programs_clients.php'>";
        
    value=".$row['id']."'>";
         echo "<input type='
    hidden' name='id' value=".$current_id."'>";
        </form>"

    Here is the a code from the update_programs_clients.php. The echo here ends up being the ID with a /' for example if the id is 3 it shows up as 3/'

    PHP Code:
    <?php
    $program_id 
    $_POST[id];
    echo 
    $program_id;
    Thanks for your help.
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,245
    Rep Power
    9400
    What you posted isn't valid PHP code. What do you actually have?
    And double-check your quoting.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    16
    Rep Power
    0
    Originally Posted by requinix
    What you posted isn't valid PHP code. What do you actually have?
    And double-check your quoting.
    Its a combo of php and html. The use of dbl and single quotes are required to make it work. I think. I modeled it after several tutorials. but maybe I am doing it wrong.

    Here is the update.php file (all the echos work find in this file)

    Code:
    <?php
    $con=mysqli_connect("ntim.db.1112222.hostedresource.com","ntime","pword","ntime");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
    
    $selSQL = "SELECT * FROM PROGRAMS order by id asc";
    
    $result = mysqli_query($con,$selSQL) or die(trigger_error(mysql_error(), E_USER_ERROR));
    
    if (mysqli_num_rows($result) > 0)//at least one record!
    {
    
          while ($row = mysqli_fetch_array($result))
    
          {
    	  $current_id=$row['id'];
    	  echo $current_id;  
    	 echo "<form method='post' action='update_programs_clients.php'>";
    	
    	 echo "<input type='hidden' name='id' value=".$current_id."'>";
    	
    	echo $row['id']; echo "&nbsp;&nbsp;&nbsp;";
        echo "<font face='Arial, Helvetica, sans-serif'>";
    	echo "Project Name: &nbsp;&nbsp;&nbsp; <span style='color:blue'>".$row['program_name']."  </span>   &nbsp;&nbsp;&nbsp;         Project Owner:   ". $row['owner_name']."&nbsp;&nbsp;&nbsp; <input type='submit' name='update' value='Update'></form>";
        echo "<hr>";
          }
    }
    
    mysqli_close($con);
    ?>
    Here is the update_programs_clients.php. The echo does who the correct ID # but its adding those two other chars: /'
    Code:
    <?php
    $program_id = $_POST[id];
    echo $program_id;
    ?>
  6. #4
  7. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Look closer at:

    PHP Code:
    echo "<input type='hidden' name='id' value=".$current_id."'>"
    You don't have an open ' for the value field.
    And are you getting back /' or \' ?

    $10 says the "closing" ' is being included in the value, passed back into your script with a \ added by PHP's deprecated magic quote functionality.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    16
    Rep Power
    0
    That was it!! thanks.

IMN logo majestic logo threadwatch logo seochat tools logo