posting code in mysql using php -


i saving code in mysql using php pdo, code not working. code is...

<?php session_start(); include 'connection.php'; $question=$_post['question']; $answer=$_post['desc']; $query = $conn->prepare("insert qa(issue,desc)values(':issue','desc')"); $query->bindparam(':issue',$question, pdo::param_str); $query->bindparam(':desc', $answer, pdo::param_str);  $query->execute();  if(!$query) {     $_session['error']='error in posting issue';     header('location:index.php');  } 

but not insert code in mysql , it data in mysql like..

:issue!

desc

but whe use query...

<?php session_start(); include 'connection.php'; $question=$_post['question']; $answer=$_post['desc']; $conn->exec("insert qa (issue,desc) values ('".$question."','".$answer."')"); if($conn) {     $_session['sucess']='issue posted successfully';     header('location:index.php');  } else {     $_session['error']='error in posting issue';     header('location:index.php');  }  ?> else  {     $_session['sucess']='issue posted successfully';     header('location:index.php');  } ?> 

then insert plane text, if write not insert database, success session call.

what want: i want if enter type of data either php code or html or css, save data base.

any highly appreciated...

try code @u_mulder said..

<?php session_start(); include 'connection.php'; $question=$_post['question']; $answer=$_post['desc']; $query = $conn->prepare("insert qa(issue, desc) values (:issue, :desc)"); $query->bindparam(':issue', $question, pdo::param_str); $query->bindparam(':desc', $answer, pdo::param_str);  $query->execute();  if(!$query) {     $_session['error']='error in posting issue';     header('location:index.php');  } 

it solve issue..


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -