Jump to content

php/mysql Populated textfield not working


jay7981

Recommended Posts

hey all,

 

I have a text field that is populated with a mysql field however it is not populating with all of the info in that field it stops at the first space of any info in the mysql field ... why would this be happening ?

 

i am using this type of setup

 

info in the mysql field of name is: John Doe Mercer

 

while($res=mysql_fetch_array($result))
{
$name = mysql_real_escape_string($res['name']);
}
echo $name;

 

Only output i get is

John

edit.php

The code you attached is dramatically different from the code you posted, and doesn't have anything like this code. Your code also stores First and Last name in separate fields (which is GOOD) but you're only echoing 'name' in your posted code.

 

 

Edit: The fact that you're running mysql_real_escape_string on values you just SELECTED from the database makes me think your code has some serious issues. 

 

You're not checking for any SQL errors either.

 

Edit 2: You ALSO are trying to use $ID before it's been defined for your update. Turn error reporting on!

the posted code was simply an example to show you all what i was running into, and yes the info in the database is what i want but is not being displayed correctly

 

Edit to answer,

i use escape_string because i dont trust user input,

i will be adding sql error checks later as the code works perfectly with the exception of the current issue i have.

i have $ID well defined for both the update and select statement before it is used.

error reporting is on (ALL) within my ini

 

again here is the code with minor mods done

edit.php

also when print_r($res) i get what i am expecting just not with the echo

 

print_r($res['Department']);

 

returns

My Favorite Department

 

but echo ($res['Department']);

 

returns

My

 

 

ive figured it out ...

 

for some reason i had to double quote the echos in the value ...

 

<input type="text" name="Department" size="55" value="<?php

echo ($res['Department']); ?>">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.