superhoops Posted August 27, 2006 Share Posted August 27, 2006 Hi my name is Michael and i have just started working with mysql today. I have a database already and want to add a table to it using sql/php code.Here is the code i have: <?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 (Player varchar(15),Price varchar(12),Type textPosition textAge int(2)Ka int(2)Ta int(2)Pa int(2)Sa int(2))";mysql_query($sql,$con);?> I have put in the password field password so noone here takes it but i was wondering what is wrong with the code or what i need to do to create the tables as i uploaded this file and went to my database and the table had not been created.Any help will be greatly appreciated.ThanksMichael Link to comment Share on other sites More sharing options...
SirPaladin Posted August 27, 2006 Share Posted August 27, 2006 You haven`t put commas between all fields. :)I hope it`s that. Link to comment Share on other sites More sharing options...
superhoops Posted August 27, 2006 Author Share Posted August 27, 2006 You haven`t put commas between all fields. :)I hope it`s that. I did that and no luck still, once i upload the file to my server do i need to do anything else to it? Link to comment Share on other sites More sharing options...
superhoops Posted August 27, 2006 Author Share Posted August 27, 2006 Sorted it out. Thanks Link to comment Share on other sites More sharing options...
SirPaladin Posted August 27, 2006 Share Posted August 27, 2006 Sorted it out. ThanksCould you be kind and tell me how? Link to comment Share on other sites More sharing options...
superhoops Posted August 27, 2006 Author Share Posted August 27, 2006 Sorted it out. ThanksDeleted the closing the connection part of it.I have another problem guysOn this page http://www.fmprotasy.com/Test/transfer_market1.phpWhen i put in information and click submit it says thisWarning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/fmprotasy.com/Test/insert.php on line 11Error:Here is the code i have for the insert page:<?php$db = mysql_connect("db5.awardspace.com:3306", "fmpsite_reg", "password") 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 (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,$con)) { die('Error: ' . mysql_error()); }?> If anyone could tell me the problem here i would be very greatful. Link to comment Share on other sites More sharing options...
superhoops Posted August 27, 2006 Author Share Posted August 27, 2006 Help would really be appreictaed. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2006 Share Posted August 28, 2006 You are trying to use a variable called $con to represent your database connection, but you never set up $con. Instead, you set up a connection called $db, but then you don't use it. Either change your references at the top to use $con instead of $db, or change your references at the bottom to use $db instead of $con. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now