Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2003, 03:57 PM
Registered User
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default DB value variables get posted as 'S'???

Hi,
I have a form set up for editing a single row of a MySQL DB. The form fields are populated with the current DB data.

e.g. <input type="text" name="myform[firstname]" value="<?php echo $myDB['Firstname']; ?>">

That part works fine. The form loads and all my data is there like it should be.

I submit this form to another php page that does the work of updating the DB with the changed entries. But when these form fields are submitted, they arrive at the next page with a value of 'S' - I wouldn't have noticed if I didn't have an email validator.

So on the work page if I echo $_POST['myform']['firstname'] I get 'S'.

What is this? What does it mean? How can I stop it? Please Tell Me!

The best ideas are not the simple ones, they're the complex ones made easy.
 
Old December 18th, 2003, 04:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Huh, that doesn't sound right. What exactly is the code snippet you're using to echo the data? And what exactly is the HTML form you've generated? I suspect that you might be somehow overwriting your myform array, maybe with a typo or something.

The first thing you should do on your page is to check the values of everything in $_POST to make sure it looks right. If it does, you know that something's being screwed up in the PHP code that receives the form. If it doesn't look right, you know that there's something wrong with your form HTML.

<?php

if (isset($_POST))
{
    echo "<pre>\$_POST is:";
    print_r($_POST);
    echo "</pre>\n";
}

// rest of your script goes here

?>


Take care,

Nik
http://www.bigaction.org/
 
Old December 22nd, 2003, 03:15 PM
Registered User
 
Join Date: Nov 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I decided to start over, and as soon as I began writing out the code I realised what I was doing wrong. On my submitting form page I was writing: name="myform['firstname']" which doesn't seem to work.

When I rewrote it as; name="myform[firstname]" (without the single quotes around firstname), everything fell into place.
Just another stupid error.

The best ideas are not the simple ones, they're the complex ones made easy.





Similar Threads
Thread Thread Starter Forum Replies Last Post
New code posted cwebb BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 May 3rd, 2007 07:41 PM
New Ajax and Yahoo! article posted jminatel Javascript 0 March 23rd, 2006 03:29 PM
New Ajax article posted jminatel Ajax 0 March 13th, 2006 07:40 PM
Passing variables to an access DB dsargent Classic ASP Databases 4 February 8th, 2006 03:39 PM
Posted topic vrbhatt Forum and Wrox.com Feedback 3 September 24th, 2003 07:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.