Karaethon Posted March 23, 2019 Share Posted March 23, 2019 (edited) I'm being given an error by mysql, "Warning: mysqli_connect() expects parameter 1 to be string, object given in /storage/...", the relevant lines are $code = $this->GenerateCode($num); $enCoded = password_hash($code, PASSWORD_BCRYPT); $query = "INSERT INTO `vaults` " . "(`Alive`, `Contents`, `Code`, `digits`, `Winning_Player_ID`, `Won_Date`, `debug`)" . "VALUES " . "(CONV('1', 2, 10) + 0, '0', '{$enCoded}', '$num', NULL, NULL, '{$code}')"; Followed by the mysqli_connect($this->db, $query). Edited March 23, 2019 by Karaethon syntax alignment Quote Link to comment https://forums.phpfreaks.com/topic/308509-php-to-mysql-insert-problem/ Share on other sites More sharing options...
mac_gyver Posted March 23, 2019 Share Posted March 23, 2019 the error is in the mysqli_connect statement call, not the posted code. Quote Link to comment https://forums.phpfreaks.com/topic/308509-php-to-mysql-insert-problem/#findComment-1565554 Share on other sites More sharing options...
Karaethon Posted March 23, 2019 Author Share Posted March 23, 2019 (edited) Palm, Face, Face, Palm. Now that you've met.... I really should have caught that, parameter 1 is not the query. ok. so... $insert = mysqli_connect($this->db, $query); I'm guessing it doesn't like "$this->db"? Edited March 23, 2019 by Karaethon Quote Link to comment https://forums.phpfreaks.com/topic/308509-php-to-mysql-insert-problem/#findComment-1565555 Share on other sites More sharing options...
mac_gyver Posted March 23, 2019 Share Posted March 23, 2019 7 minutes ago, Karaethon said: I'm guessing it doesn't like "$this->db"? there's no guessing in programming. it is an exact science. you must know what the input parameters are, what the statement does, and what value is returned. mysqli_connect is NOT used to execute a query. Quote Link to comment https://forums.phpfreaks.com/topic/308509-php-to-mysql-insert-problem/#findComment-1565559 Share on other sites More sharing options...
Karaethon Posted March 23, 2019 Author Share Posted March 23, 2019 (edited) Face, Palm, Palm, Face. I didn't even catch that! ok, maybe I should take a mental health day for the rest of the day. mysqli_query, not mysqli_connect... write that 500 times on the blackboard Karæthon. Edited March 23, 2019 by Karaethon Quote Link to comment https://forums.phpfreaks.com/topic/308509-php-to-mysql-insert-problem/#findComment-1565561 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.