and this is my function i used to call the query to update the values in the database:
function updatabout($detailsarr)
{
$query = "UPDATE User_details SET Marital_status='" .
$detailsarr['m_status'] . "', Ethnicity='" .
$detailsarr['ethinicity'] . "', Primary_language='" .
$detailsarr['language'] . "', Education_level='" .
$detailsarr['education'] .
"' WHERE User_id=".$_SESSION['uid'];
$queryresult = mysql_query($query);
echo mysql_error().'<br />'.$query;
}
here all the data are saving into my database except the “hobby” field and the value of the hobby field is showing as “undefined” in my database, as well as after clicking the save button, i’m getting the alerts & query what i used here but the values are displaying on the page only after refreshing the page…can anyone please letme know what the fault i’ve in this code…thanks in advance..
UPDATE ok, Now I see you have edited and corected the mistake in your code in question. But still
<?php =$hobby ?>doesn’t make sense to me. It tells nothing to do to PHP parser. Useechothere, as explained in my answer.The only possible explanation of your problem is that the code being used in producing the
hobbyinput field, specifically this fragmentvalue=<?=$hobby?>is having problem.Reason:
PHP processes a
<?and<?differently. Former is echoed as-it-is, and latter tells PHP that PHP code is started at this point, and process it. Then an un-neccesarry=and missing;.Solution:
First of all use
value="<?php echo $hobby; ?>"Use of full PHP tags () is always recommended over short tags () Then you need to tell PHP to echo/print the value of$hobbyhere by usingecho. Now the output HTML should bevalue="_Some_Hobby_"Now, if still the output HTML is
value=""i.e. empty, then you need to check if$hobbyactually holds a value.As seen at http://codepad.org/dvf9bwSd in Case 3,
PHP Parser just chunks out the
<php .... ?>thing as-it-is. So use literal<&>.Now, in Case 1,
echoing
$hobbyvariable without assigning it any value prints nothing. Andvar_dumpalso returnsNULLMoving on to case-2,
defining/assigning a value to
$hobbyand then echoing it gives us the desired resultvalue="Coding"andvar_dumpalso says it is aStringoflength=6