How to Update this Table? using Php / Mysql -


code in "inc/q/prof.php":

<?php // insert comments database user provides $comm = mysql_real_escape_string($_post['addcomment']);  // following line has changed: $pid4 = filter_var( $_post['pid'], filter_sanitize_string );  $commentdetail = $_post['addcomment']; $username = "###"; $password = "###"; $pdo4 = new pdo('mysql:host=localhost;dbname=####', $username, $password); $pdo4->setattribute( pdo::attr_errmode, pdo::errmode_exception ); $sth4 = $pdo4->prepare(' insert comment (info, pid, cid) values(?,?,?)  select comm.cid professor p, comment comm, course cou  p.pid = comm.pid , cou.cid = comm.cid; ');  $sth4->execute(array($commentdetail, $pid4, $cid ));   ?> 

html

<form action='inc/q/prof.php' method='post'>                     <input type='text' id='addcomment' name='addcomment' tabindex='3' value='enter comment' />                 <input type='hidden' name='pid' value='<?php echo $pid4; ?>'>                  </form> 

tables: comm course prof

error still received - still getting error: you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'select comm.cid professor p, comment comm, course cou p.pid = comm.p' @ line 2\pdostatement->execute(array) #1

you can pass them both hidden input fields. appears though have pid:

<input type="hidden" name="pid" value="<?php echo $pid4 ?>" /> 

also, ensure posting correct fields , values. add following top of prof.php:

print_r($_post); 

my guess not passing $_post['pid']


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -