BenAlcock Posted February 21, 2013 Share Posted February 21, 2013 I have a database already created in MySQL called "accounts" and im trying to insert a new table called "test". I am using XAMPP Control Panel: v3.1.0.3.1.0, XAMPP: v1.8.1 [php: 5.4.7] and MySQL: v5.5.27. I am very new to PHP (only been learning for a few days). I would appreciate any attempts of trying to help me. - Ben <?php $accounts = mysql_connect("localhost", "root", "qazwsxedc") or die (mysql_error()); mysql_select_db("accounts",$accounts); $sql = "CREATE TABLE test ( ID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(ID), Username varchar(20), Password varchar(20), First name varchar(20), Last name varchar(20) )"; mysql_query($sql, $accounts); ?> Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 21, 2013 Share Posted February 21, 2013 I've always cheated and just used phpmyadmin, then when you've created the table through that interface, you can export the sql and see what it should be in code, should you need to keep it in a deployment script or something.. Quote Link to comment Share on other sites More sharing options...
clarky0 Posted February 21, 2013 Share Posted February 21, 2013 I am also new to .php but i am fairly confident your database name wouldn't just be called accounts it would be "yourdomai'_accounts (i purposely missed the "n" on domain because the last letter of your domain name wont be included in the DB name Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2013 Share Posted February 21, 2013 I am also new to .php but i am fairly confident your database name wouldn't just be called accounts it would be "yourdomai'_accounts (i purposely missed the "n" on domain because the last letter of your domain name wont be included in the DB name Uhm, please don't give advice when you literally have no idea what you're talking about. What you're describing sounds like a setup from a specific hosting company. OP is using XAMPP for localhost development. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted February 21, 2013 Share Posted February 21, 2013 Debug the call to mysql_query() and determine if it is in fact returning a resource: mysql_query($sql, $accounts) or die("Mysql Error: " . mysql_error()); Also make sure that error_reporting() is set to E_ALL or -1 and display_errors() is ON Quote Link to comment Share on other sites More sharing options...
Barand Posted February 21, 2013 Share Posted February 21, 2013 Don't put spaces in column names Quote Link to comment Share on other sites More sharing options...
clarky0 Posted February 21, 2013 Share Posted February 21, 2013 (edited) Uhm, please don't give advice when you literally have no idea what you're talking about. What you're describing sounds like a setup from a specific hosting company. OP is using XAMPP for localhost development. Wow, sorry i will keep my mouth shut next time. Reason i said what i said is because i had a mySQL problem a while ago and it was due to DB name being incorrect even though my CP said it was correct Edited February 21, 2013 by clarky0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.