An7hony Posted February 2, 2011 Share Posted February 2, 2011 How would i return the id in the echo of this post: $query = "INSERT INTO jobs SET agent = '".mysql_real_escape_string($agent)."', title = '".mysql_real_escape_string($title)."', location = '".mysql_real_escape_string($location)."', salary_from = '".$salary_from."', salary_to = '".$salary_to."', frequency = '".$frequency."', jobtype='".$jobtype."', description='".$description."', email = '".$email."', created_at = '".$created_at."', closing_date ='".$closing_date."', categories = '".$categories."', sectors = '".$sectors."', ref='".$ref."'"; if(mysql_query($query)) { echo "Job inserted!"; } else { die(mysql_error()); } Thanks for the help guys Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/ Share on other sites More sharing options...
trq Posted February 2, 2011 Share Posted February 2, 2011 mysql_insert_id. Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/#findComment-1168790 Share on other sites More sharing options...
An7hony Posted February 2, 2011 Author Share Posted February 2, 2011 so just to confirm i would write this echo "Job inserted!", mysql_insert_id(); Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/#findComment-1168795 Share on other sites More sharing options...
trq Posted February 2, 2011 Share Posted February 2, 2011 The concatination operator is . not , Why don't you try some code instead of wasting your time wondering? Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/#findComment-1168802 Share on other sites More sharing options...
PaulRyan Posted February 2, 2011 Share Posted February 2, 2011 @Thorpe You can use , OR . to echo that string and MySQL id. Infact using , is faster if you're just echo-ing the data and . is used if you are assigning the data to a variable to concatenate* Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/#findComment-1168806 Share on other sites More sharing options...
An7hony Posted February 2, 2011 Author Share Posted February 2, 2011 cool thanks guys echo "Job inserted!", mysql_insert_id(); worked fine Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/#findComment-1168816 Share on other sites More sharing options...
trq Posted February 2, 2011 Share Posted February 2, 2011 @Thorpe You can use , OR . to echo that string and MySQL id. Infact using , is faster if you're just echo-ing the data and . is used if you are assigning the data to a variable to concatenate* Indeed. I always forget echo accepts more than one argument. Quote Link to comment https://forums.phpfreaks.com/topic/226444-returning-the-id-in-an-echo/#findComment-1168817 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.