Spraban9 Posted March 22, 2013 Share Posted March 22, 2013 hi friends i have the error in update coding plz help me to solve this problem <?php if($_POST['comf'] != ''){ /*$name = $_POST['name']; */ $comf = $_POST['comf']; include("include/connection.php"); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database , $conn) or die (mysql_error()); /* $result = "UPDATE customer SET active = 1 WHERE randomno='$comf' "; $que=mysqli_query($r)or die(mysql_error()); $que=mysql_query("select active from customer where user='$name'"); if($que) {*/ $que1=mysql_query($conn,"UPDATE customer SET active = 1 WHERE randomno ='$comf' ") ; if (!$que1 ){ die("Database query failed: ". mysql_error()); } else { /*$saved= "Error in conformation code please retype"; */ $saved= "Thank you to Activate Your Account "; } } ?> <label id="dis"> <h3><?php echo $saved?> </h3></label><br> <form name="frmconfor" id="frmconfor" method="post" action="comformation.php"> <table width="536" height="265" id="font" > <!-- <tr> <td height="62" class="style9"><label>UserName</label></td> <td><input required name="name" type="text" value="" /></td> </tr>--> <tr> <td height="62" class="style9"><label>Conformation Code</label></td> <td><input required name="comf" type="text" value="" /></td> </tr> <tr> <td height="118" colspan="2"> <div align="center"> <input name="submit" type="submit" value="submit"/> </div></td> </tr> </table> </form></center> Quote Link to comment https://forums.phpfreaks.com/topic/275999-warning-mysql_query-expects-parameter-1-to-be-string/ Share on other sites More sharing options...
mikosiko Posted March 22, 2013 Share Posted March 22, 2013 what is not clear in the error message that you are getting?.... if it is not self evident... read the "Description" here: http://php.net/manual/en/function.mysql-query.php P.S: (not related to the error that you are getting) You should use the mysqli API or PDO instead of mysql API.. it has been soft deprecated already. Quote Link to comment https://forums.phpfreaks.com/topic/275999-warning-mysql_query-expects-parameter-1-to-be-string/#findComment-1420249 Share on other sites More sharing options...
Spraban9 Posted March 22, 2013 Author Share Posted March 22, 2013 this is error that i m geting Warning: mysql_query() expects parameter 1 to be string, resource given in F:\xampp\htdocs\cleanred\comformation.php on line 99Database query failed: Quote Link to comment https://forums.phpfreaks.com/topic/275999-warning-mysql_query-expects-parameter-1-to-be-string/#findComment-1420253 Share on other sites More sharing options...
Spraban9 Posted March 22, 2013 Author Share Posted March 22, 2013 hi this coding to showing error but update not working <?php if(isset($_POST['update'])){ $comf = $_POST['comf']; include("include/connection.php"); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database , $conn) or die (mysql_error()); $que1="update customer set active = 1 where randomno ='$comf' " ; mysql_select_db('vas'); $retval = mysql_query( $que1, $conn ); if(! $retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data successfully\n"; mysql_close($conn); } else { ?> <label id="dis"> <h3><?php echo $saved?> </h3></label><br> <form name="frmconfor" id="frmconfor" method="post" action="<?php $_PHP_SELF ?>"> <table width="536" height="265" id="font" > <tr> <td height="62" class="style9"><label>Conformation Code</label></td> <td><input required name="comf" type="text" value="" /></td> </tr> <tr> <td height="118" colspan="2"> <div align="center"> <input name="update" type="submit" id="update" value="Update"> </div></td> </tr> </table> </form> <?php } ?> </center> it show the "update successfuly "message but no change in database Quote Link to comment https://forums.phpfreaks.com/topic/275999-warning-mysql_query-expects-parameter-1-to-be-string/#findComment-1420255 Share on other sites More sharing options...
Spraban9 Posted March 22, 2013 Author Share Posted March 22, 2013 hi this coding to showing error but update not working <?php if(isset($_POST['update'])){ $comf = $_POST['comf']; include("include/connection.php"); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database , $conn) or die (mysql_error()); $que1="update customer set active = 1 where randomno = $comf " ; mysql_select_db('vas'); $retval = mysql_query( $que1, $conn ); if(! $retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data successfully\n"; mysql_close($conn); } else { ?> <label id="dis"> <h3><?php echo $saved?> </h3></label><br> <form name="frmconfor" id="frmconfor" method="post" action="<?php $_PHP_SELF ?>"> <table width="536" height="265" id="font" > <tr> <td height="62" class="style9"><label>Conformation Code</label></td> <td><input required name="comf" type="text" value="" /></td> </tr> <tr> <td height="118" colspan="2"> <div align="center"> <input name="update" type="submit" id="update" value="Update"> </div></td> </tr> </table> </form> <?php } ?> it show the "update successfuly "message but no change in database Could not update data: Unknown column 'kmrlyOBOYv' in 'where clause' Quote Link to comment https://forums.phpfreaks.com/topic/275999-warning-mysql_query-expects-parameter-1-to-be-string/#findComment-1420258 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.