ikon32
asked on
unable to create table mysql php
Hi experts, I have this simple php script below. It is not creating the table in to mysql.
Can you please check it out and possibly find where the error in the code is?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gr" xml:lang="gr">
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="StyleSheet" type="text/css" href="code/main.css" />
</head>
<body>
<div style="position:absolute; left:0px; top:0px; right:0px;width:100%; height:100%; padding:0px; margin:0px; text-align:left;">
start
<?php
include "code/dbinfo.inc.php";
mysql_connect(localhost,$u sername,$p assword);
mysql_select_db($database) or die( "Unable to select database");
mysql_query("CREATE TABLE pediko_tbl ( // it does not create the table here
id int(6) NOT NULL auto_increment,
link_th varchar(100) NOT NULL,
link varchar(100) NOT NULL,
UNIQUE KEY (link_th))")or die( "Unable to create table");
mysql_query("SET NAMES 'utf8'");
$i=0;
if ($handle = opendir('path')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
mysql_query("INSERT INTO pediko_tbl VALUES('','$file' , '$file')");
echo "$file";
$i++;
}
}
closedir($handle);
}
mysql_close();
echo "all $i inserted";
?>
</div>
</body>
</html>
Can you please check it out and possibly find where the error in the code is?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gr" xml:lang="gr">
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="StyleSheet" type="text/css" href="code/main.css" />
</head>
<body>
<div style="position:absolute; left:0px; top:0px; right:0px;width:100%; height:100%; padding:0px; margin:0px; text-align:left;">
start
<?php
include "code/dbinfo.inc.php";
mysql_connect(localhost,$u
mysql_select_db($database)
mysql_query("CREATE TABLE pediko_tbl ( // it does not create the table here
id int(6) NOT NULL auto_increment,
link_th varchar(100) NOT NULL,
link varchar(100) NOT NULL,
UNIQUE KEY (link_th))")or die( "Unable to create table");
mysql_query("SET NAMES 'utf8'");
$i=0;
if ($handle = opendir('path')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
mysql_query("INSERT INTO pediko_tbl VALUES('','$file' , '$file')");
echo "$file";
$i++;
}
}
closedir($handle);
}
mysql_close();
echo "all $i inserted";
?>
</div>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PS. ignore the "thegamepoker." in front of the table name. I was testing it in my environment. :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Big thanks to all, your comments were excellent. I had to accept all as correct answers cause the solution I guess was a combination... found that out after I tried all your solutions. thanks so much!
1. Primary
Open in new window
2. Unique
Open in new window