php - prepared statements UPDATE -
i getting below error when try update query using mysqli prepared statements. wrong error message why unexpected? help.
parse error: syntax error, unexpected '$prob' (t_variable)
here query
$mysqli = new mysqli("localhost", "root", "", "newlogin"); if ($mysqli->connect_errno) { echo "failed connect mysql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $check = $mysqli->prepare("select * `vpb_uploads` `username` = ? , `firstname` = '' , `image_one` != ''"); $check->bind_param('s', $username); $check->execute(); $check->store_result(); if($check->num_rows < 1) { echo '<div class="vpb_error_info" align="left">sorry, seems have not added file yet.<br>please click on add files button first of add @ least 1 file before submitting details. thanks...</div>'; } else { $firstname = trim(strip_tags($_post["firstname"])); $lastname = trim(strip_tags($_post["lastname"])); if( $prob = $mysqli->prepare("update `vpb_uploads` set `firstname` = ?, `lastname` = ? `username` = ? , `firstname` = '' , `image_one` != ''") $prob->bind_param('sss', $firstname, $lastname, $username); $prob->execute(); ) { echo '<font style="font-size:0px;">success</font>'; echo '<div class="vpb_error_info" align="left">congrats <b>'.$firstname.' '.$lastname.'</b>, details have been submitted successfully. thanks...</div>'; }
try code:
$mysqli = new mysqli("localhost", "root", "", "newlogin"); if ($mysqli->connect_errno) { echo "failed connect mysql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $check = $mysqli->prepare("select * `vpb_uploads` `username` = ? , `firstname` = '' , `image_one` != ''"); $check->bind_param('s', $username); $check->execute(); $check->store_result(); if($check->num_rows < 1){ echo '<div class="vpb_error_info" align="left">sorry, seems have not added file yet.<br>please click on add files button first of add @ least 1 file before submitting details. thanks...</div>'; } else { $firstname = trim(strip_tags($_post["firstname"])); $lastname = trim(strip_tags($_post["lastname"])); $prob = $mysqli->prepare("update `vpb_uploads` set `firstname` = ?, `lastname` = ? `username` = ? , `firstname` = '' , `image_one` != ''") ; if ($prob){ $prob->bind_param('sss', $firstname, $lastname, $username); $success = $prob->execute(); if ($success){ echo '<font style="font-size:0px;">success</font>'; echo '<div class="vpb_error_info" align="left">congrats <b>'.$firstname.' '.$lastname.'</b>, details have been submitted successfully. thanks...</div>'; } } }
Comments
Post a Comment