Youngie Posted August 12, 2009 Share Posted August 12, 2009 Used my script to create a new table within the database but get these errors: Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/findme/public_html/PHP/create_Table.php on line 33 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/findme/public_html/PHP/create_Table.php on line 33 no TABLE created. You have problems in the system already, backtrack and debug! Thing is I have declared in connect_to_mysql the username and password, but it fails to connect when I declare that I required connect_to_mysql <?php require_once "connect_to_mysql.php"; print "Success in database file CONNECTION.....<br />"; $result="CREATE TABLE myMembers ( id int(11) NOT NULL auto_increment, firstname varchar(255) NOT NULL, lastname varchar(255) NOT NULL, address1 varchar(255) NOT NULL, address2 varchar(255) NOT NULL, state varchar(255) NOT NULL, city varchar(255) NOT NULL, zip varchar(255) NOT NULL, phone varchar(255) NOT NULL, bio_body text NOT NULL, email varchar(255) NOT NULL, password varchar(255) NOT NULL, sign_up_date date NOT NULL default '0000-00-00', last_log_date date NOT NULL default '0000-00-00', account_type varchar(255) NOT NULL default 'client_type_1', account_notes varchar(255) NOT NULL, email_activated enum('0','1') NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY email (email) ) "; if (mysql_query($result)){ echo "Success in TABLE creation!...... <br /><br /><b>delete file now<br /> named 'create_Table.php' and you are ready to move on. Let us go!</b>"; } else { echo "no TABLE created. ERROR!"; } exit(); ?> Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2009 Share Posted August 12, 2009 You don't have a connection to the database server at that time the mysql_query() statement is being executed. You would need to troubleshoot why the php code in your connect_to_mysql.php file is not making a connection. If you want us to help with that, you would need to post the code in connect_to_mysql.php. xxxxx out any sensitive information, but don't change any of the syntax in the file and post the opening php tag that is in the file. Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896531 Share on other sites More sharing options...
Youngie Posted August 12, 2009 Author Share Posted August 12, 2009 You don't have a connection to the database server at that time the mysql_query() statement is being executed. You would need to troubleshoot why the php code in your connect_to_mysql.php file is not making a connection. If you want us to help with that, you would need to post the code in connect_to_mysql.php. xxxxx out any sensitive information, but don't change any of the syntax in the file and post the opening php tag that is in the file. Nice one mate, thanks for the quick reply. Here it is: <?php $db_host = "localhost"; $db_username = "findme_xxx"; $db_pass = "xx"; $db_name = "findme_xxx"; $myConnection = mysqli_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896533 Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2009 Share Posted August 12, 2009 You are creating a mysqli connection, but using a non-mysqli_ function. You cannot mix mysql and mysqli functions on one connection. Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896536 Share on other sites More sharing options...
Youngie Posted August 12, 2009 Author Share Posted August 12, 2009 You are creating a mysqli connection, but using a non-mysqli_ function. You cannot mix mysql and mysqli functions on one connection. Ahhh I see, sorry I'm learning, PHP and SQL isn't my language of choice lol. Now there is no errors but, the table is not created. no TABLE created. You have problems in the system already, backtrack and debug! Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896538 Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2009 Share Posted August 12, 2009 For debugging, use mysql_error()/mysqli_error($myConnection) in your error message to get mysql to tell you why the query failed. Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896542 Share on other sites More sharing options...
Youngie Posted August 12, 2009 Author Share Posted August 12, 2009 For debugging, use mysql_error()/mysqli_error($myConnection) in your error message to get mysql to tell you why the query failed. Doesn't say anything, can you say where this is meant to go? Says connection success, then it's blank. EDIT - No database selected Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896548 Share on other sites More sharing options...
Youngie Posted August 12, 2009 Author Share Posted August 12, 2009 Sorry to bump, does anyone know? 100% the database has been created and user exists. Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896628 Share on other sites More sharing options...
PFMaBiSmAd Posted August 12, 2009 Share Posted August 12, 2009 No database selected You need to select a database before you execute a query or you could specify the database in the query using the db_name.table_name syntax instead of just table_name syntax. The mysqli_connect() 4th parameter is the database name or if using mysql, see the mysql_select_db() function. Quote Link to comment https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896652 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.