Jump to content


Photo

Whats the Problem With This???


  • This topic is locked This topic is locked
12 replies to this topic

#1 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 12:54 PM

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);
?>

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 August 2006 - 12:57 PM

mysql_query($sql,$con) or die(mysql_error());


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 01:15 PM

Thanks.

I now get this message;

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

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());
?>

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 August 2006 - 01:25 PM

looks to me like you have a comma after

Sa int(2),

that doesn't belong there.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 01:31 PM

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

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

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?

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 August 2006 - 01:35 PM

looks like you forgot a "

'$_POST[ATT]')";
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 01:40 PM

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?

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 August 2006 - 01:42 PM

click the browse tab
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#9 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 01:48 PM

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.

#10 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 August 2006 - 01:54 PM

check to make sure the $_POST variable names are the same as what you have in your form.

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#11 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 02:06 PM

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.

#12 superhoops

superhoops
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 28 August 2006 - 02:18 PM

Does anyone know why when people submit info in a text area/box it doesn't display it on the database?

#13 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 28 August 2006 - 02:58 PM

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....html#msg423352

Thread closed.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users