Jump to content

Archived

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

superhoops

Whats the Problem With This???

Recommended Posts

Why is this not creating a table in my databse?

<?php
$con = mysql_connect("db5.awardspace.com:3306","fmpsite_reg","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
// Create table in fmpsite_reg database
mysql_select_db("fmpsite_reg", $con);
$sql = "CREATE TABLE Market
(
id INT AUTO_INCREMENT PRIMARY KEY,
Player varchar(15),
Price varchar(12),
Type text,
Position text,
Age int(2),
Ka int(2),
Ta int(2),
Pa int(2),
Sa int(2),
)";
mysql_query($sql,$con);
?>

Share this post


Link to post
Share on other sites
Thanks.

I now get this message;

[b]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 ')' at line 13[/b]

Here is the code of my page that creates the table

<?php
$con = mysql_connect
("db5.awardspace.com:3306","fmpsite_reg","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
// Create table in fmpsite_reg database
mysql_select_db("fmpsite_reg", $con);
$sql = "CREATE TABLE Market
(
id INT AUTO_INCREMENT PRIMARY KEY,
Player varchar(15),
Price varchar(12),
Type text,
Position text,
Age int(2),
Ka int(2),
Ta int(2),
Pa int(2),
Sa int(2),
)";
mysql_query($sql,$con) or die(mysql_error());
?>

Share this post


Link to post
Share on other sites
looks to me like you have a comma after

Sa int(2)[b][color=red],[/color][/b]

that doesn't belong there.

Share this post


Link to post
Share on other sites
Thanks alot mate, the table is created now.

I have a form which sends information to insert.php which sends the information to the database but when i submit the form i get this error

[b]Parse error: syntax error, unexpected $end in /home/www/fmprotasy.com/Test/insert.php on line 33[/b]

Here is the code for the insert.php page

<?php
$db = mysql_connect("db5.awardspace.com:3306", "fmpsite_reg",

"pitstop") or die("Could not connect.");
if(!$db)
die("no db");
if(!mysql_select_db("fmpsite_reg",$db))
die("No database selected.");
if(!get_magic_quotes_gpc())
mysql_select_db("fmprotasy_reg", $con);
$sql="INSERT INTO Market (id,
Player,
Price,
Type,
Position,
Age,
Ka,
Ta,
Pa,
Sa)
VALUES ('',
'$_POST[Player]',
'$_POST[Price]',
'$_POST[Type]',
'$_POST[Position]',
'$_POST[Age]',
'$_POST[GK]',
'$_POST[DEF]',
'$_POST[MID]',
'$_POST[ATT]');
if (!mysql_query($sql,$db))
  {
  die('Error: ' . mysql_error());
  }
?>

Would you be able to tell me where i am going wrong?

Share this post


Link to post
Share on other sites
Thank You so much! It works!

Now in phpmyadmin, i have logged on, click on the correct table, how do i view the information submitted?

Share this post


Link to post
Share on other sites
Ah yes the Browse tab thanks.

I have another problem. 3 of the fields don't display any information even though everything in the form was filled in.

These fields are Player, Price and Position.

Sorry but if you know how to get around this i will be very greatful.

Share this post


Link to post
Share on other sites
Ha Ha. I have edited 1 of them and it worked, the other 2 are correct though. Would it be that the 2 which don't show up are both parts of forms where you put in text so maybe something in the form or databse might be wrong?

Your the expert, if you could identify the problem it would be great.

Share this post


Link to post
Share on other sites
Does anyone know why when people submit info in a text area/box it doesn't display it on the database?

Share this post


Link to post
Share on other sites
OK, STOP POSTING THE SAME PROBLEM in multiple threads.

Keep all your related questions in a single thread.  It helps other people who are interested in solving a similar problem AND it means that people who respond don't find there are other people responding to the same problem in different threads.

I suggest you continue the one and only discussion on this in the thread http://www.phpfreaks.com/forums/index.php/topic,105862.msg423352.html#msg423352

Thread closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

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.