Quantcast
Channel: WampServer - WampServer English
Viewing all articles
Browse latest Browse all 3177

HOW TO FIX: FATAL ERROR: UNCAUGHT ERROR: CALL TO UNDEFINED FUNCTION (no replies)

$
0
0
I created a database and about to create a table but got the following errors:

! ) Fatal error: Uncaught Error: Call to undefined function CREATE TABLE MyGuests ( id INT(6 UNSIGNED
AUTO_INCREMENT PRIMARYKEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR (30) NOT NULL, email

VARCHAR (50), reg_date TIMESTAMP )() in C:\wamp\www\php\revision\mysql\create table obj.php on line 27
( ! ) Error: Call to undefined function CREATE TABLE MyGuests ( id INT(6 UNSIGNED AUTO_INCREMENT PRIMARYKEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR (30) NOT NULL, email VARCHAR (50), reg_date TIMESTAMP )() in C:\wamp\www\php\revision\mysql\create table obj.php on line 27
Call Stack
# Time Memory Function Location
1 0.0707 386320 {main}( ) ...\create table obj.php:0 .
Here is my code:
<!DOCTYPE html>
<html>
<body>

<?php
$servername = "Localhost";
$username = "root";
$password = "";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

//Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error());
}

//sql to create table
$sql = "CREATE TABLE MyGuests (
id INT(6 UNSIGNED AUTO_INCREMENT PRIMARYKEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR (30) NOT NULL,
email VARCHAR (50),
reg_date TIMESTAMP
)";

if ($conn->query($sql() === TRUE)) {
echo "Table MyGuests created successfully";
}else{
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>

</body>
</html>


I have checked and wondered how the function is undefined.Please help

Viewing all articles
Browse latest Browse all 3177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>