Jump to content


Photo

Create table help pls


  • Please log in to reply
4 replies to this topic

#1 snake310

snake310
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 20 September 2006 - 08:46 AM

Hi i have read tonns of tutorials but i cant figure out what could be the problem pls help me...
He wont write it to the database the wariables named $get1 and $producer works fine , at least as i echo them they show the right walue
<?php
mysql_pconnect("localhost","root")
                  or die("Unable to connect to SQL server");
mysql_select_db("$get1") or die ("No Conn");
if(!$producer)
$x=1;
else {
$sql = 'CREATE TABLE $producer ('.
        '`model` varchar(60) NOT NULL default 0,'.
        '`serial` varchar(60) NOT NULL default 0,'.
'`InTime` date NOT NULL default 0,'.
'`provider` varchar(60) NOT NULL default 0,'.
'`aviz` varchar(60) NOT NULL default 0,'.
'`OutTime` date NOT NULL default 0,'.
'`add1` varchar(60) NOT NULL default 0,'.
'`add2` varchar(60) NOT NULL default 0,'.
'`add3` varchar(60) NOT NULL default 0,'.
        '`buyer` varchar(60) NOT NULL default 0,.
      )';
 
$result = mysql_query($sql) or die ("Fail");}
?>

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 20 September 2006 - 09:57 AM

What errors are being output to the browser?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 snake310

snake310
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 20 September 2006 - 09:59 AM

i get error :    Fail

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 20 September 2006 - 10:22 AM

OK, do you have phpMyAdmin installed?

If not I'd strongly advise getting it.  Then you can test the sql works before testing the php.  As it is, there's nothing wrong with the php.

It's all the '.' you have.

Just get rid of them and insert the following:

<?php
$sql = "CREATE TABLE $producer (
`model` varchar(60) NOT NULL default 0,
`serial` varchar(60) NOT NULL default 0,
`InTime` date NOT NULL default 0,
`provider` varchar(60) NOT NULL default 0,
`aviz` varchar(60) NOT NULL default 0,
`OutTime` date NOT NULL default 0,
`add1` varchar(60) NOT NULL default 0,
`add2` varchar(60) NOT NULL default 0,
`add3` varchar(60) NOT NULL default 0,
`buyer` varchar(60) NOT NULL default 0)";
?>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 snake310

snake310
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 20 September 2006 - 10:28 AM

Thx problem solved  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users