Jump to content

Create table help pls


snake310

Recommended Posts

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");}
?>
Link to comment
https://forums.phpfreaks.com/topic/21378-create-table-help-pls/
Share on other sites

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:

[code]
<?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)";
?>
[/code]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/21378-create-table-help-pls/#findComment-95197
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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