Jump to content

[SOLVED] creating mysql table using php


rinteractive

Recommended Posts

This is my code

 

<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?php

$con = mysql_connect("localhost","root","");

if(!$con)

{

echo"Connection failed".mysql_error();

}

 

 

 

mysql_select_db("sample",$con);

$sql="CREATE TABLE member

( id  int(11) NOT NULL auto_increment,

 

membership_no varchar(100) ,

refcode varchar(100),

post varchar(100),

photo varchar(100),

  cat int(11),

name varchar(100),

head int (11),

date_of_birth date,

Gender varchar(10),

profession varchar(50),

nationality varchar(30),

education varchar(30),

familydetails1 varchar(50),

familydetails2 varchar(50),

address1 varchar(100),

address2 varchar(100),

telephoner int (15),

telephoneo int (15),

mobile int (15),

email varchar(80),

policestation varchar (70),

municipalityoffice varchar(100),

detailsofbank varchar(100)

date1 date,

place varchar(30),

 

PRIMARY KEY  (id),

  KEY `membership_no` (`membership_no`)

 

)";

mysql_query($sql,$con);

 

mysql_close($con);

?>

</body>

</html>

 

the table is not creating

 

Could any one help me

Link to comment
https://forums.phpfreaks.com/topic/82651-solved-creating-mysql-table-using-php/
Share on other sites

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
echo"Connection failed".mysql_error();
}



mysql_select_db("sample",$con);
$sql="CREATE TABLE member
( id  int(11) NOT NULL auto_increment,

membership_no varchar(100) ,
refcode varchar(100),
post varchar(100),
photo varchar(100),
  cat int(11),
name varchar(100),
head int (11),
date_of_birth date,
Gender varchar(10),
profession varchar(50),
nationality varchar(30),
education varchar(30),
familydetails1 varchar(50),
familydetails2 varchar(50),
address1 varchar(100),
address2 varchar(100),
telephoner int (15),
telephoneo int (15),
mobile int (15),
email varchar(80),
policestation varchar (70),
municipalityoffice varchar(100),
detailsofbank varchar(100)
date1 date,
place varchar(30),

PRIMARY KEY  (id),
  KEY `membership_no` (`membership_no`)

)";
mysql_query($sql,$con) or die(mysql_error());

mysql_close($con);
?>
</body>
</html>

 

Try that (mySQL will report errors now)

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
echo"Connection failed".mysql_error();
}



mysql_select_db("sample",$con);
$sql="CREATE TABLE member
( id  int(11) NOT NULL auto_increment,

membership_no varchar(100) ,
refcode varchar(100),
post varchar(100),
photo varchar(100),
  cat int(11),
name varchar(100),
head int (11),
date_of_birth date,
Gender varchar(10),
profession varchar(50),
nationality varchar(30),
education varchar(30),
familydetails1 varchar(50),
familydetails2 varchar(50),
address1 varchar(100),
address2 varchar(100),
telephoner int (15),
telephoneo int (15),
mobile int (15),
email varchar(80),
policestation varchar (70),
municipalityoffice varchar(100),
detailsofbank varchar(100)   /* forgot here to put camma (,) */
date1 date,
place varchar(30),

PRIMARY KEY  (id),
  KEY `membership_no` (`membership_no`)

)";
mysql_query($sql,$con) or die(mysql_error());

mysql_close($con);
?>
</body>
</html>



Thanks you for replying me

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.