Jump to content

php with mysql


redarrow

Recommended Posts

advance thank you...

 

i am currently learning how to do php with mysql so i dont need to use the mysql

console but the table dosent go on the database..

 

please help cheers..

 

no errors just the table dosent create cheers....

 

 

 

<?php


$db=mysql_connect(" sec"," sec"," sec");

$query='CREATE DATABASE database_test';

$result=mysql_query($query)or die('<center><b>Database exists please delete database or change database name</b></center>');

mysql_select_db('database_test',$db)or die('could not select database');

$query2='CREATE TABLE members('.
                              'id INT NOT NULL AUTO_INCREMENT'.',PRIMARY_KEY(id))';

$result2=mysql_query($query2)or die("Table error");

echo"database created and tables";

mysql_close($db);

?>



 

 

 

Link to comment
Share on other sites

tried it this way aswell but no luck the table wont create....

 

<?php

// database connection...

// 1. Conection  2. Username 3. Password

$db=mysql_connect("sec","sec","sec");

// 1. The $query 2. CREATE DATABASE 3. databse name

$query='CREATE DATABASE database_test';

$result=mysql_query($query)or die('<center><b>Database exists please delete database or change database name</b></center>');

mysql_select_db('database_test')or die('could not select database');

$query='CREATE TABLE members ('.
                              'id INT NOT NULL AUTO_INCREMENT,'.' PRIMARY_KEY(id))';

$result=mysql_query($query)or die("Table error");

echo"database created and tables";

mysql_close($db);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.