I am getting the error:
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\Apache\htdocs\movie\actor_form\demo.php:9 Stack trace: #0 {main} thrown in C:\Apache\htdocs\movie\actor_form\demo.php on line 9
When I try to enter data into my database via a php form. Here are my two scripts:
demo.php file:
<?php
define('DB_Name', 'movies');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysqlI_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
$actfn = $_POST['Actor First Name'];
$actln = $_Post['Actor Last Name'];
$actag = $_POST['Actor Age'];
$actgn = $_POST['Actor Gender'];
$actht = $_POST['Actor Height'];
$sql = "INSERT INTO actor_demographics (Actor_First_Name, Actor_Last_Name, Actor_Age, Actor_Gender, Actor_Height) VALUES ('$actfn', '$actln', '$actag', '$actgn', '$actht')";
if (!mysql_query($sql)) {
die('ERROR: ' . mysql_error());
}
mysql_close();
?>
demo-form.php file:
<form action="demo.php" method="post" />
<p>Actor First Name: <input type="text" name="Actor First Name" /><p>
<p>Actor Last Name: <input type="text" name="Actor Last Name" /><p>
<p>Actor Age: <input type="text" name="Actor Age" /><p>
<p>Actor Gender: <input type="text" name="Actor Gender" /><p>
<p>Actor Height: <input type="text" name="Actor Height" /><p>
<input type="submit" value="Submit" />
</form>
Line 9 that the error is referencing is:
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
There have been other posting on this matter that state I need to remove the ; on the command
;extension=php_mysqli.dll
found in my php.ini file
I have tried removing this semicolon and have added it back in and am still receiving the error.
Any help would be greatly appreciated.
Thank you
Php.ini edited file:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir ="C:/php/ext"
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client