Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
using php to load a mysql table on my local machine
Old 11-23-2007, 04:41 PM using php to load a mysql table on my local machine
matt w's Avatar
Super Talker

Posts: 136
Location: kalamazoo
Trades: 0
I am using the instructions in the tutorial at: http://www.freewebmasterhelp.com/tutorials/phpmysql/3
to load my local mysql table called "contacts" in my local database "local_db" with data. I can't connect to the database. I get this error message:
Notice: Use of undefined constant localhost - assumed 'localhost' in c:\program files\easyphp1-8\www\new folder\load_contacts.php on line 6

Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in c:\program files\easyphp1-8\www\new folder\load_contacts.php on line 6
Unable to select database
my php code is in easyphp1-8\www\new folder\load_contacts.php.
Is the "new folder" location OK?
The code of contacts.php is:
PHP Code:
<?php
$username
="";
$password="";
$database="local_db";
mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
mysql_query($query);
$query "INSERT INTO contacts VALUES ('','John','Smith','01234 567890','00112 334455','01234 567891','johnsmith@gowansnet.com','http://www.gowansnet.com')";
mysql_close();
?>
What am I doin'?
Thanks in advance!
matt w is offline
Reply With Quote
View Public Profile Visit matt w's homepage!
 
 
Register now for full access!
Old 11-23-2007, 05:01 PM Re: using php to load a mysql table on my local machine
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
localhost needs to be your IP, for example

"81.938.534.35"
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 11-23-2007, 07:47 PM Re: using php to load a mysql table on my local machine
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Localhost should have been in quotes. If the database is local then localhost is correct. This should work.
PHP Code:
 <?php
$username
="";
$password="";
$database="local_db";
$host="localhost";
$connection mysql_connect($host,$username,$password);
mysql_select_db($database,$connection) or die( "Unable to select database");

$query "INSERT INTO contacts VALUES ('','John','Smith','01234 567890','00112 334455','01234 567891','johnsmith@gowansnet.com','http://www.gowansnet.com')";
mysql_query($query);
mysql_close();
?>
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 11-24-2007, 11:31 AM Re: using php to load a mysql table on my local machine
matt w's Avatar
Super Talker

Posts: 136
Location: kalamazoo
Trades: 0
Quote:
Originally Posted by maxxximus View Post
Localhost should have been in quotes. If the database is local then localhost is correct. This should work.
PHP Code:
 <?php
$username
="";
$password="";
$database="local_db";
$host="localhost";
$connection mysql_connect($host,$username,$password);
mysql_select_db($database,$connection) or die( "Unable to select database");
 
$query "INSERT INTO contacts VALUES ('','John','Smith','01234 567890','00112 334455','01234 567891','johnsmith@gowansnet.com','http://www.gowansnet.com')";
mysql_query($query);
mysql_close();
?>
Using your code (thank you!) I get this error message:

Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in c:\program files\easyphp1-8\www\new folder\load_contacts.php on line 6

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in c:\program files\easyphp1-8\www\new folder\load_contacts.php on line 7
Unable to select database

I need to find out my username and password don't I! Is that it?
matt w is offline
Reply With Quote
View Public Profile Visit matt w's homepage!
 
Old 11-24-2007, 12:44 PM Re: using php to load a mysql table on my local machine
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Default installation; username is 'root', if you didn't set a password then leave blank.

$username="root";
$password="";
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to using php to load a mysql table on my local machine
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22849 seconds with 12 queries