mysql - PHP randomly printing code within php tags -


i wrote php/sql intention of storing session variables sql table. (i left out html tells user php worked.)

<?php session_start(); $name = $_request["name"]; $type = $_request["type"]; $lengthnum = $_request["lengthnum"]; $rewardnum = $_request["rewardnum"]; $itemreward = $_request["itemreward"];  $dsn = "mysql:host=localhost;dbname=xxxxxx"; $username = "xxxxxxxxx"; $pw = "xxxxxxxx"; $options = array(pdo ::attr_errmode=>pdo ::errmode_exception); try {     $my_pdo = new pdo ($dsn, $username, $pw, $options);     $sql_stmt = "insert xxxxxx (name, type, length, reward, item)                  values ($name, $type, $lengthnum, $rewardnum, $itemreward)";     $my_pdo->query($sql_stmt); } catch(exception $a) {     echo "<p>error..." . $a->getmessage() . "</p>"; } ?> 

for reason code "breaks" out of php tags after "$options = array(" , output html file.

pdo ::errmode_exception); try { $my_pdo = new pdo ($dsn, $username, $pw, $options); $sql_stmt = "insert simplewfa (name, type, length, reward, item) values ($name, $type, $lengthnum, $rewardnum, $itemreward)"; $my_pdo->query($sql_stmt); } catch(exception $a) { echo "  error..." . $a->getmessage() . " "; } ?> 

thanks!

just guess i'd array definition invalid.

$options = array(pdo ::attr_errmode=>pdo ::errmode_exception); 

should like

$options = array("pdo::attr_errmode"=>"pdo::errmode_exception"); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -