sql - Server 500 error when php script is run -


i testing php script inserting database in sql server. weird bug , did research couldn't determine causing it. error getting 500 internal server error. have tried printing out error no avail.

if( $conn ) { echo "connection established.<br />"; $fname=$_post['firstname'];  $lname=$_post['lastname'];  $sql = "insert testtable (userfirstname, userlastname) values (?, ?)"; $params = array("$fname", "$lname"); $stmt = sqlsrv_query( $conn, $sql, $params);     if( $stmt === false ) {         echo sqlsrv_errors();     }     else {         echo "data transmitted successfully.<br />"     } }     

the script above breaks. weird thing when comment out if($stmt === false) etc, script runs fine , data gets inserted.

if( $conn ) { echo "connection established.<br />"; $fname=$_post['firstname'];  $lname=$_post['lastname'];  $sql = "insert testtable (userfirstname, userlastname) values (?, ?)"; $params = array("$fname", "$lname"); $stmt = sqlsrv_query( $conn, $sql, $params); //  if( $stmt === false ) { //      echo sqlsrv_errors(); //  } //  else { //      echo "data transmitted successfully.<br />" //  } } 

the above code works. ideas causing on webserver?

speaking of webserver, running through godaddy's web hosting service. in particular, using plesk windows hosting.

you trying use echo, accepts strings argument, giving sqlsrv_errors argument, returns array. think reason why 500 error.

try use print_r() or var_dump() instead :

if( $stmt === false ) {     var_dump(sqlsrv_errors);die; } 

link manual : http://php.net/manual/fr/function.sqlsrv-errors.php


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -