can create database but not tables

This is a discussion on "can create database but not tables" within the Databases section. This forum, and the thread "can create database but not tables are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Sep 15th, 2007, 20:57
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
can create database but not tables

i am trying to create a database with tables via injection, but i am having problems, it will create the database, but not the tables, can you see what is wrong here , thank you

Code: Select all
<?
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db  = 'CREATE DATABASE saltyblog';
$result = mysql_query($db);
mysql_select_db('saltyblog') or die('Cannot select database');
// Create a MySQL table in the selected database
$sql = 'CREATE TABLE `FORM` ('
        . ' `title` TEXT NOT NULL, '
        . ' `date` DATE NOT NULL, '
        . ' `subject` VARCHAR(30) NOT NULL, '
        . ' `blog message` TEXT NOT NULL'
        . ' )'; 
mysql_close($link);
?>
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Sep 16th, 2007, 00:32
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

Quote:
Originally Posted by saltedm8 View Post
i am trying to create a database with tables via injection, but i am having problems, it will create the database, but not the tables, can you see what is wrong here , thank you

Code: Select all
<?
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db  = 'CREATE DATABASE saltyblog';
$result = mysql_query($db);
mysql_select_db('saltyblog') or die('Cannot select database');
// Create a MySQL table in the selected database
$sql = 'CREATE TABLE `FORM` ('
        . ' `title` TEXT NOT NULL, '
        . ' `date` DATE NOT NULL, '
        . ' `subject` VARCHAR(30) NOT NULL, '
        . ' `blog message` TEXT NOT NULL'
        . ' )'; 
mysql_close($link);
?>
PHP: Select all

$sql "CREATE TABLE FORM (
        title TEXT NOT NULL,
        date DATE NOT NULL,
        subject VARCHAR(30) NOT NULL,
        blog message` TEXT NOT NULL
        )"

that's it i think
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Sep 16th, 2007, 00:34
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

and you have to query it:

PHP: Select all

mysql_query($sql); 

Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Sep 16th, 2007, 10:39
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

very weird, its still not working, i must be missing something somewhere, but i am getting no errors
Code: Select all
<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db  = 'CREATE DATABASE saltyblog';
$result = mysql_query($db);
$sql = mysql_select_db('saltyblog') or die('Cannot select database');
// Create a MySQL table in the selected database
mysql_query($sql);  
    $sql='CREATE TABLE `form` (
        `title` TEXT NOT NULL 
        `date` VARCHAR(25) NOT NULL 
        `subject` VARCHAR(30) NOT NULL 
        `blog_mes` TEXT NOT NULL ) ;' 
 
 
?>
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Sep 16th, 2007 at 10:43.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Sep 16th, 2007, 10:52
Reputable Member
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: can create database but not tables

instead of

'CREATE TABLE `form` (

try

CREATE TABLE `form` (
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Sep 16th, 2007, 10:54
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

Parse error: parse error in c:\program files\easyphp1-8\www\new folder (2)\input.php on line 15
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Sep 16th, 2007, 11:18
Reputable Member
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: can create database but not tables

line 15 I think is this

`blog_mes` TEXT NOT NULL ) ;'

TRY `blog_mes` TEXT NOT NULL );
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Sep 16th, 2007, 11:29
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

nope, still the same - i think line 15 is this
Code: Select all
    $sql=CREATE TABLE `form` (
- as soon as you took out the hyphen, i got the error, - before i was getting no errors, it was just not creating the tables
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Sep 16th, 2007, 11:43
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

you have an excessive amount of uneeded apostrophes
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Sep 16th, 2007, 11:48
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

so which do i need, and which dont i need ? , i took this the 'create table' bit straight from the database

i have tryed this

Code: Select all
mysql_query($sql);  
    $sql='CREATE TABLE form (
        title TEXT NOT NULL 
        date VARCHAR(25) NOT NULL 
        subject VARCHAR(30) NOT NULL 
        blog_mes TEXT NOT NULL ) ';
but still no luck
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)

Last edited by saltedm8; Sep 16th, 2007 at 11:52.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Sep 16th, 2007, 12:04
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

for one thing you need $sql to be before the query
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Sep 16th, 2007, 12:10
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

no error, but still no tables

Code: Select all
 $sql='CREATE TABLE form (
        title TEXT NOT NULL 
        date VARCHAR(25) NOT NULL 
        subject VARCHAR(30) NOT NULL 
        blog_mes TEXT NOT NULL ) ';
   
  
mysql_query($sql);
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Sep 16th, 2007, 13:59
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

Quote:
Originally Posted by saltedm8 View Post
no error, but still no tables

Code: Select all
 $sql='CREATE TABLE form (
        title TEXT NOT NULL 
        date VARCHAR(25) NOT NULL 
        subject VARCHAR(30) NOT NULL 
        blog_mes TEXT NOT NULL ) ';
   
  
mysql_query($sql);
no commas in there, try this one:

Code: Select all
 $sql="CREATE TABLE form (
        title TEXT NOT NULL,
        date VARCHAR(25) NOT NULL, 
        subject VARCHAR(30) NOT NULL, 
        blog_mes TEXT NOT NULL ) ";
   
  
mysql_query($sql) or die (mysql_error());
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Sep 16th, 2007, 15:57
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

that did it, thank you very much very
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Sep 16th, 2007, 15:58
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

you're welcome
you know how to put data aswell?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Sep 16th, 2007, 16:00
saltedm8's Avatar
SuperMember

SuperMember
Join Date: Nov 2005
Location: here
Age: 27
Posts: 1,523
Blog Entries: 2
Thanks: 1
Thanked 11 Times in 11 Posts
Re: can create database but not tables

how to insert data you mean ?

this ?
SELECT * FROM `form` WHERE 1

or INSERT INTO ?
Last Blog Entry: Strict and Transitional Doctype's (Sep 12th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Sep 16th, 2007, 16:04
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: can create database but not tables

Quote:
Originally Posted by saltedm8 View Post
how to insert