Reputation: 768
hey guys i got following error Undefined index: hname in C:\Temp\5Aug2010\job.php on line 38
this error occur in insert command i use
'".mysql_real_escape_string($_POST['hname'])."'
where hname is a textbox field on form
if i use
'".mysql_real_escape_string((isset($_POST['hname'])))."'
then error will gone but in database it show empty field.
Upvotes: 0
Views: 1019
Reputation: 449783
If you need to stay inside that string you quote, use
".(!empty($_POST['hname']) ? mysql_real_escape_string($_POST['hname']) : null)."
but for readability's sake, it would be nicer to do before outputting the string:
if (!empty($_POST['hname']))
$hname = mysql_real_escape_string($_POST['hname']);
else
$hname = null;
Upvotes: 1