Jump to content

Recommended Posts

Can anyone tell me why this isn't working?

<?php
include ('DB_config.php');

mysql_query('DROP TABLE IF EXISTS `users`')  
or die(mysql_error());  

mysql_query('CREATE TABLE IF NOT EXISTS `users` (
  id int(11) NOT NULL auto_increment,
  date date NOT NULL default 0000-00-00 00:00:00,
  title varchar(255) NOT NULL default,
  name varchar(255) NOT NULL default,
  surname varchar(15) NOT NULL default ,
  sex varchar(15) NOT NULL default,
  post varchar(15) NOT NULL default,
  mobile varchar(25) NOT NULL default,
  age varchar(25) NOT NULL default,
  transport varchar(255) NOT NULL default,
  file varchar(255) NOT NULL default,
  PRIMARY KEY(id))')  
or die(mysql_error());  
?>

 

I keep getting this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-00-00 00:00:00, title varchar(255) NOT NULL default, name varchar(255) NOT ' at line 3

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/86312-solved-mysql-insert-why-this-dont-work/
Share on other sites

I changed date to signup instead

 

Now I'm getting this

 

Parse error: syntax error, unexpected T_LNUMBER in /home/celtic-teambuild/public_html/sign/install.php on line 9

 

 

 

Do I have to enclose every field name with a `

Try this sql:

mysql_query('CREATE TABLE IF NOT EXISTS `users` (
  id int(11) NOT NULL auto_increment,
  date date NOT NULL default \'0000-00-00 00:00:00\',
  title varchar(255) NOT NULL default,
  name varchar(255) NOT NULL default,
  surname varchar(15) NOT NULL default ,
  sex varchar(15) NOT NULL default,
  post varchar(15) NOT NULL default,
  mobile varchar(25) NOT NULL default,
  age varchar(25) NOT NULL default,
  transport varchar(255) NOT NULL default,
  file varchar(255) NOT NULL default,
  PRIMARY KEY(id))')  
or die(mysql_error()); 

Hope this will solve your problem

--

Thanks,

Tapos Pal

http://tapos.wordpress.com

Thanks tapos, it didn't work, but I did this

 

mysql_query('CREATE TABLE IF NOT EXISTS `users` (
  id int(11) NOT NULL auto_increment,
  date date NOT NULL default \'0000-00-00 00:00:00\',
  title varchar(255) NOT NULL default \'\',
  name varchar(255) NOT NULL default \'\',
  surname varchar(15) NOT NULL default \'\',
  sex varchar(15) NOT NULL default \'\',
  post varchar(15) NOT NULL default \'\',
  mobile varchar(25) NOT NULL default \'\',
  age varchar(25) NOT NULL default \'\',
  transport varchar(255) NOT NULL default \'\',
  file varchar(255) NOT NULL default \'\',
  PRIMARY KEY(id))')  
or die(mysql_error()); 

 

And it worked perfectly!

 

Thanks

That's where I obtained the code in the first place.

 

I was trying to make it easy for this person.

 

I built the database for them, but I couldn't get access to phpmyadmin on their servier, so I build a install file, access it, ad viola! done.

 

Thanks for everyone's help

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.