Solarpitch Posted May 28, 2007 Share Posted May 28, 2007 Hi Guys, I have the following code that executes when someone has entered there email into the form . . although $email is set, it seems to execute the code but with the error "Warning: mysqli_query() expects parameter 1 to be mysqli, null given in m line 141" I dont know why because $email has been set to a valid address. if($email != "") { $mysql_connect = new mysqli("xxx", "xxx", "xxx"); $mysql_connect->select_db('xxx'); $query = "select * from members where email = '$email'"; $result = mysqli_query( $mysql, $query ); ****LINE 141**** if(!$result) { echo 'Cannot run query.'; exit; } $count = mysqli_num_rows($result); if ( $count > 0 ){ $email_in_use = "Email address already exists."; $execute = "no"; } else { echo "Email not found"; } } Quote Link to comment https://forums.phpfreaks.com/topic/53304-solved-mysqli_query-expects-parameter-1-to-be-mysqli/ Share on other sites More sharing options...
Barand Posted May 28, 2007 Share Posted May 28, 2007 At which point in your code did $mysql get assigned a value? $result = mysqli_query( $mysql, $query ); ****LINE 141**** Quote Link to comment https://forums.phpfreaks.com/topic/53304-solved-mysqli_query-expects-parameter-1-to-be-mysqli/#findComment-263507 Share on other sites More sharing options...
Solarpitch Posted May 28, 2007 Author Share Posted May 28, 2007 Ah thats what is! I should be using $mysql_connect . . thanks Quote Link to comment https://forums.phpfreaks.com/topic/53304-solved-mysqli_query-expects-parameter-1-to-be-mysqli/#findComment-263520 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.