Ask a Question related to PHP Development, Design and Development.
-
Keith W. McCammon #1
Using PHP to Print SELECT Results - Incomplete Data Returned
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
Keith W. McCammon Guest
-
Referencing array results returned to Flex via a RemoteObject Call
Hi, Here's the RO result using the NetConnection Debugger. I have a function that can always read the first array element, but the others... -
Altering a results returned to a ASP
Hey guys, thank you for all the help i've recieved recently from this newsgroup. I've not another problem which I was hoping someone might be able... -
limiting rows returned in a sql select
ceprnatwork@hotmail.com (the dragon) wrote in message news:<6e59cc25.0308200651.6edb0e2@posting.google.com>... I dont know why "fetch first ...",... -
DB2 Select - how to return a range of results
Hi, Here is some SQL from MS SQL 2000: select top 5 * from (select top 5 * from (select top 25 code, name, address from contacts where name... -
Replace character in SELECT results
Hi, I have a SELECT statement of multiple columns from joined tables. One of the columns is an address field. It is one field that contains the... -
Tom Thackrey #2
Re: Using PHP to Print SELECT Results - Incomplete Data Returned
On 13-Nov-2003, "Keith W. McCammon" <km@km.com> wrote:
enclose the value in quotes <input ... value="<? print $data['street'];> 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!
?>"...>
(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
[url]www.creative-light.com[/url]
tom (at) creative (dash) light (dot) com
do NOT send email to [email]jamesbutler@willglen.net[/email] (it's reserved for spammers)
Tom Thackrey Guest
-
kafooey #3
Re: Using PHP to Print SELECT Results - Incomplete Data Returned
On Thu, 13 Nov 2003 13:56:44 -0500, "Keith W. McCammon" <km@km.com>
wrote:
You don't need the single quotes on the fieldnames.>SELECT
>`last_name`,`first_name`,`street`,`city`,`state`, `zip`,`area_code`,`phone`,`
>email`,`badge`
>FROM $table
>WHERE `last_name` = 'mccammon' AND `first_name` = 'keith'
try...>And when I use <? print $data[street] ?> to print the `street` value within
>the text box, all I see is:
print $data["street"];
kafooey
- [email]kafooey@nospam.yahoo.co.uk[/email]
- [url]http://www.pluggedout.com/blog[/url]
kafooey Guest
-
Keith W. McCammon #4
Re: Using PHP to Print SELECT Results - Incomplete Data Returned
Thanks, Tom! That did the trick. Always the easy stuff that gets me...
Keith W. McCammon Guest
-
Keith W. McCammon #5
Re: Using PHP to Print SELECT Results - Incomplete Data Returned
Thanks for the suggestion. Enclosing this alone in quotes doesn't do it,
but enclosing the value itself does.
Keith W. McCammon Guest
-
kafooey #6
Re: Using PHP to Print SELECT Results - Incomplete Data Returned
On Thu, 13 Nov 2003 19:18:34 GMT, kafooey <kafooey@nospam.yahoo.co.uk>
wrote:
Of course... just re-read your question...>try...
> print $data["street"];
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
- [email]kafooey@nospam.yahoo.co.uk[/email]
- [url]http://www.pluggedout.com/blog[/url]
kafooey Guest



Reply With Quote

