By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Using PHP to Print SELECT Results - Incomplete Data Returned

P: n/a
So this little problem has stumped me for close to an hour, and I know it's
something easy...

I'm using PHP to select field values from a record in a MySQL database, and
display those values inside of text boxes in a form (which is used to allow
folks to update records). The SELECT statement:

SELECT
`last_name`,`first_name`,`street`,`city`,`state`,` zip`,`area_code`,`phone`,`
email`,`badge`
FROM $table
WHERE `last_name` = 'mccammon' AND `first_name` = 'keith'

This is called via a standard connect string, the functional portion of
which looks like this:

$result=MYSQL_QUERY($query) or die(mysql_error());
$data=mysql_fetch_array($result);

This all works great, *but* the `street` value normally looks like this:

2000 L Street NW

And when I use <? print $data[street] ?> to print the `street` value within
the text box, all I see is:

2000

Apparently the first space in the field value is the end of the road, for
some reason. I'm guessing this is something easy to handle, but I'm a
novice here, so please go easy!

Thanks

Keith

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

On 13-Nov-2003, "Keith W. McCammon" <km@km.com> wrote:
I'm using PHP to select field values from a record in a MySQL database,
and
display those values inside of text boxes in a form (which is used to
allow
folks to update records). The SELECT statement:

SELECT
`last_name`,`first_name`,`street`,`city`,`state`,` zip`,`area_code`,`phone`,`
email`,`badge`
FROM $table
WHERE `last_name` = 'mccammon' AND `first_name` = 'keith'

This is called via a standard connect string, the functional portion of
which looks like this:

$result=MYSQL_QUERY($query) or die(mysql_error());
$data=mysql_fetch_array($result);

This all works great, *but* the `street` value normally looks like this:

2000 L Street NW

And when I use <? print $data[street] ?> to print the `street` value
within
the text box, all I see is:

2000

Apparently the first space in the field value is the end of the road, for
some reason. I'm guessing this is something easy to handle, but I'm a
novice here, so please go easy!


enclose the value in quotes <input ... value="<? print $data['street'];
?>"...>
(You should also enclose street in apostrophies unless you've defined it as
a constant or are using it in a quoted string.)

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

P: n/a
On Thu, 13 Nov 2003 13:56:44 -0500, "Keith W. McCammon" <km@km.com>
wrote:
SELECT
`last_name`,`first_name`,`street`,`city`,`state`, `zip`,`area_code`,`phone`,`
email`,`badge`
FROM $table
WHERE `last_name` = 'mccammon' AND `first_name` = 'keith'
You don't need the single quotes on the fieldnames.
And when I use <? print $data[street] ?> to print the `street` value within
the text box, all I see is:


try...
print $data["street"];

kafooey
- ka*****@nospam.yahoo.co.uk
- http://www.pluggedout.com/blog
Jul 17 '05 #3

P: n/a
Thanks, Tom! That did the trick. Always the easy stuff that gets me...
Jul 17 '05 #4

P: n/a
On Thu, 13 Nov 2003 19:18:34 GMT, kafooey <ka*****@nospam.yahoo.co.uk>
wrote:
try...
print $data["street"];


Of course... just re-read your question...

You need to make sure you put your value within quotes in the form
input tag.

(see the other reply).

I guess this is a case of RTFQ :)

kafooey
- ka*****@nospam.yahoo.co.uk
- http://www.pluggedout.com/blog
Jul 17 '05 #5

P: n/a
Thanks for the suggestion. Enclosing this alone in quotes doesn't do it,
but enclosing the value itself does.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.