Jump to content

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

Edited by jay7981

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!

Edited by Jessica

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

Edited by jay7981

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']); ?>">

Edited by jay7981
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.