Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/169950-error-nobodylocal/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896531
Share on other sites

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

?>

Link to comment
https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896533
Share on other sites

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!

 

Link to comment
https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896538
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896548
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/169950-error-nobodylocal/#findComment-896652
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.