Hi Guys, I am breaking my head for this error for an hour. Could you help me soon?? The code below is not retriving data from Database. $course_id = CS100; $query = 'SELECT * FROM comments WHERE CourseID = "$course_id" '; But when i try this $query = 'SELECT * FROM comments WHERE CourseID = "CS100" '; It is working...... Reply me soon please
Variables are not parsed between single quotes. Do it like this: $course_id = 'CS100'; $query = "SELECT * FROM comments WHERE CourseID = '$course_id'"; PHP:
Try this: [COLOR=#0000ff]$course_id[/COLOR] = [COLOR=#ff0000]'CS100'[/COLOR]; [COLOR=#0000ff]$query[/COLOR] = [COLOR=#ff0000]"SELECT * FROM comments WHERE CourseID = $course_id"[/COLOR]; Code (markup):
It is Working as nico_swd said Thank you very much Hi babyboy808 I tried that also but was giving the same Error. Anyhow it is corrected. Thank you
just to clarify things up, I think the most right / wise way to do the query is like this..for me, it's more visible to human eyes.. $course_id = CS100; $query = "SELECT * FROM comments WHERE CourseID = '".$course_id."' "; PHP: