Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_fetch_array weird results

Status
Not open for further replies.

treyhunsucker

Programmer
May 16, 2006
60
US
Hello,

This is a piece of code from my script:

Code:
$result = mysql_query("SELECT complete.a2, dn_records.number FROM complete, dn_records WHERE complete.c3=dn_records.number AND dn_records.number='$data1'")
or die(mysql_error());

while($row = mysql_fetch_array( $result )) {
    echo $row[0];
    echo "<input type=text name=clec_customer value=" . $row[0] . ">";
}

The problem is that "echo $row[0]" echos "119 N Broadway" and the same thing inside the text box echos "119"

$row[0] echos the a2 information, I also switched everything from $row[0] to $row[a2] and had the same results.

Any Ideas?
 
This is a PHP question not a mysql one, but, the problem you are having is neither.

The problem you are having is that values for text boxes need to be surrounded in quotes be it single or double, otherwise the value is taken up to the first space. Whatever follows the space is considered a new attribute for the text box declaration, so try to do this:

Code:
 echo "<input type=text name=clec_customer value=[red]'[/red]" . $row[0] . "[red]'[/red]>";

I added a single quote before and after the value.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
You are welcome.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hello,

In another instance I tried:

echo "<a href=update4.php?data='" . $row[0] . "'>Test Link</a>";

But again it didn't echo anything after the space
 
another example of what I've tried:

echo "<a href=update3.php?data=" . "{$row["0"]}" . ">Test Link</a>";

$row["0"] is this: Link Test

In the example above, only "Link" prints, instead of "Link Test
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top