Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Problem in Creating and Inserting Values

Codes here !

Moderators: macek, egami, gesf

Problem in Creating and Inserting Values

Postby BandanaChaudhury » Mon Feb 11, 2013 8:45 am

I am creating a Table, but I am unable to find the error, that why it is not create, Please help me,
Here's the code

<?php

$servername = "localhost";
$username = "root";
$password = "";
$connect = mysql_connect($servername, $username, $password) or die(mysql_error());

// Create table
mysql_select_db("bctravels", $connect);
$create_table = "CREATE TABLE m_seats
(
sno int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(sno),
room_category varchar(50),
twin int(5),
double int(5),
total int(5),
pass_cap int(5)
)";

//execute query
mysql_query($create_table, $connect);

// Inserting values into table
mysql_query ("INSERT INTO m_seats (room_category, twin, double, total, pass_cap)
VALUES
('Delux Cabin', 15, 5, 20, 40),
('Junior Suite', 12, 6, 18, 36),
('Suite', 0, 4, 4, 8),
('Presidential Suite (has a double and a twin room)', 0, 0, 1, 4)");
BandanaChaudhury
New php-forum User
New php-forum User
 
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Re: Problem in Creating and Inserting Values

Postby php9 » Fri Feb 22, 2013 2:51 am

Check the return value of mysql_error(), it will tell if the description of the problem (if it's a problem with your query or database connection).
php9
New php-forum User
New php-forum User
 
Posts: 13
Joined: Fri Feb 22, 2013 2:20 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron