Using PHP to Print SELECT Results - Incomplete Data Returned

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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 ...",...
    4. 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...
    5. 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...
  3. #2

    Default Re: Using PHP to Print SELECT Results - Incomplete Data Returned


    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
    [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

  4. #3

    Default 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:
    >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
    - [email]kafooey@nospam.yahoo.co.uk[/email]
    - [url]http://www.pluggedout.com/blog[/url]
    kafooey Guest

  5. #4

    Default 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

  6. #5

    Default 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

  7. #6

    Default 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:
    >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
    - [email]kafooey@nospam.yahoo.co.uk[/email]
    - [url]http://www.pluggedout.com/blog[/url]
    kafooey Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139