Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

php code with tables

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

php code with tables

Postby faris » Mon Jan 21, 2013 9:18 pm

HELLO DEAR!!!

I have created a simple tables with two fields through phpmyadmin and mysqlconsole. But when i am trying to do same thing through php code i fail though i know the code.
Code: Select all
<!DOCTYPE html>
<html>
<body>
<?php
// checking connection
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 else
 {
 echo"connection ok";
 }
 //create database
 if( mysql_query("CREATE DATABASE tutorial",$con))
 {
 echo"database created";
 }
 else
 {
 echo"problem is creation of database".mysql_error();
 }
 //create table
 mysql_select_db("tutorial", $con);
 mysql_query ( "CREATE TABLE jak
 (
 name varchar(15),
 age int(3),
 e.mail varchar(20),
  )
 

 mysql_close($con);
  ?>
</body>
</html>
faris
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Jan 21, 2013 8:35 pm

Re: php code with tables

Postby hiochou » Thu Jan 24, 2013 7:06 am

I think you forgot some characters :)

mysql_query ( "CREATE TABLE `jak`
(
name varchar(15),
age int(3),
email varchar(20)
)");

these code works well..
User avatar
hiochou
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Jan 24, 2013 6:59 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

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

cron