Search code examples
phpmysqlhtmlxamppcreate-table

Doesn't create MySQL table on XAMPP


I'm using XAMPP and practice for my upcoming exams. I am trying to create a new table in phpMyAdmin in a database. The code is:

<?php
$kapcsolat = mysql_connect("127.0.0.1","root","jelszo");    
mysql_select_db("gyakorlas", $kapcsolat);   
?>

<html>
<head>
<title>MySQL alapok</title>
</head>

<body>


<?php

$parancs = "CREATE TABLE uj_tabla ( 
(`id` BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`nev` VARCHAR(100)   CHARACTER SET latin2 COLLATE latin2_hungarian_ci NOT NULL , 
`eletkor` INT(3) NOT NULL , 
INDEX (`nev`,`eletkor`)) 
ENGINE = InnoDB CHARSET=latin2 COLLATE latin2_hungarian_ci;";

mysql_query($parancs);
?>


</body>

</html>

<?php
mysql_close($kapcsolat);
?>

I get no error messages, and when i check phpMyAdmin, it doesn't create the table in my database:(

If anyone can help me out with this, i will be very grateful!


Solution

  • First of all: mysql_* functions are deprecated. use mysqli_* or, my preferred: PDO.

    You should use prepared stamements.

    Actual answer:

    You have an error in your SQL syntax. Try running the query in phpmyadmin to see whats wrong.

    My guess is the second ( here:

    CREATE TABLE uj_tabla ( 
    ( <-