Emu Posted December 12, 2019 Share Posted December 12, 2019 I am making a simple form, but when trying to send all the information to my database the code doesn't seem to work. I don't know how much about php and would appreciate if you could check what the problem is. When I displayed errors it said the error is in the 21. line with $stmt->bind_param. <?php ini_set('display_errors', 1); $gender = $_POST['gender']; $opinionb = $_POST['opinionb']; $opinionn = $_POST['opinionn']; $host = "localhost"; $dbUsername = "*"; $dbPassword = "*"; $dbname = "*"; $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname); if (mysqli_connect_error()) { die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error()); } else { $INSERT = "INSERT Into register (gender, opinionb, opinionn) values(?, ?, ?)"; $stmt = $conn->prepare($INSERT); $stmt->bind_param('sss', $gender, $opinionb, $opinionn); $stmt->execute(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/ Share on other sites More sharing options...
gw1500se Posted December 12, 2019 Share Posted December 12, 2019 What is the error? Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572466 Share on other sites More sharing options...
Emu Posted December 12, 2019 Author Share Posted December 12, 2019 Fatal error: Uncaught Error: Call to a member function bind_param() on bool in /var/www/html/insert.php:21 Stack trace: #0 {main} thrown in /var/www/html/insert.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572467 Share on other sites More sharing options...
Barand Posted December 12, 2019 Share Posted December 12, 2019 Put this line of code immediately before your line containing mysqli_connect mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); That should get itt to report automatically any mysqli errors (such as the prepare() failing. Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572468 Share on other sites More sharing options...
Emu Posted December 12, 2019 Author Share Posted December 12, 2019 (edited) 9 minutes ago, Barand said: Put this line of code immediately before your line containing mysqli_connect mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); That should get itt to report automatically any mysqli errors (such as the prepare() failing. Fatal error: Uncaught mysqli_sql_exception: Table '*.register' doesn't exist in /var/www/html/insert.php:20 Stack trace: #0 /var/www/html/insert.php(20): mysqli->prepare('INSERT Into reg...') #1 {main} thrown in /var/www/html/insert.php on line 20 I have the table made in phpmyadmin, but it isn't under mysql structure. That shouldn't be the problem, right? Edited December 12, 2019 by Emu Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572469 Share on other sites More sharing options...
Barand Posted December 12, 2019 Share Posted December 12, 2019 You have a database named "*" !? Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572470 Share on other sites More sharing options...
Emu Posted December 12, 2019 Author Share Posted December 12, 2019 2 minutes ago, Barand said: You have a database named "*" !? No. I just changed all of that info. Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572471 Share on other sites More sharing options...
Barand Posted December 12, 2019 Share Posted December 12, 2019 So does it now work OK? Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572472 Share on other sites More sharing options...
Emu Posted December 12, 2019 Author Share Posted December 12, 2019 (edited) 8 minutes ago, Barand said: So does it now work OK? Fatal error: Uncaught mysqli_sql_exception: Table 'test.register' doesn't exist in /var/www/html/insert.php:20 Stack trace: #0 /var/www/html/insert.php(20): mysqli->prepare('INSERT Into reg...') #1 {main} thrown in /var/www/html/insert.php on line 20 Still throws out this. Found the problem. Had the register name wrong. Edited December 12, 2019 by Emu Found solution Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572473 Share on other sites More sharing options...
gw1500se Posted December 12, 2019 Share Posted December 12, 2019 (edited) From command line: mysql -u <root user> -p >use test; >show tables; Post that output. Edited December 12, 2019 by gw1500se Quote Link to comment https://forums.phpfreaks.com/topic/309676-html-form-to-phpmyadmin-error/#findComment-1572474 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.