superhoops Posted August 28, 2006 Share Posted August 28, 2006 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 databasemysql_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);?> Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 mysql_query($sql,$con)[b] or die(mysql_error())[/b]; Link to comment Share on other sites More sharing options...
superhoops Posted August 28, 2006 Author Share Posted August 28, 2006 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 databasemysql_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());?> Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 looks to me like you have a comma after Sa int(2)[b][color=red],[/color][/b] that doesn't belong there. Link to comment Share on other sites More sharing options...
superhoops Posted August 28, 2006 Author Share Posted August 28, 2006 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? Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 looks like you forgot a " '$_POST[ATT]')[b][color=red]"[/color][/b]; Link to comment Share on other sites More sharing options...
superhoops Posted August 28, 2006 Author Share Posted August 28, 2006 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? Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 click the browse tab Link to comment Share on other sites More sharing options...
superhoops Posted August 28, 2006 Author Share Posted August 28, 2006 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. Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 check to make sure the $_POST variable names are the same as what you have in your form. Link to comment Share on other sites More sharing options...
superhoops Posted August 28, 2006 Author Share Posted August 28, 2006 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. Link to comment Share on other sites More sharing options...
superhoops Posted August 28, 2006 Author Share Posted August 28, 2006 Does anyone know why when people submit info in a text area/box it doesn't display it on the database? Link to comment Share on other sites More sharing options...
AndyB Posted August 28, 2006 Share Posted August 28, 2006 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#msg423352Thread closed. Link to comment Share on other sites More sharing options...
Recommended Posts