Solved

MySQL connection problem

Posted on 2009-07-08
4
310 Views
Last Modified: 2013-12-13
For some reason I can't establish a mysql connection using this code.
I'm getting the error load -Incorrect table name ''  in my browser.

What could be the reason?
<?PHP
$DATABASE_SERVER = ':/tmp/mysql.sock';
 
$client_flags = 128; 
 
$dblink = mysql_connect($DATABASE_SERVER, 'username', 'password', FALSE, $client_flags); 
mysql_select_db('usall', $dblink); 
 
$sql = "LOAD DATA LOCAL INFILE 'data/$file' INTO TABLE `$table` FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\\\\' LINES TERMINATED BY '\r\n'(id,company,address,city,state,zip,route,altaddress,altcity,altstate,altzip,altroute,county,telephone,fax,web,lname,fname,title,gender,employees,employeerange,sales,salesrange,sic,category,alphascore,numericscore,squarefootage,pc,area)"; 
 
$result = mysql_query($sql, $dblink) or die("load -" . mysql_error()); 
echo "<h3>Import Completed!</h3><br>	\n"; 
?>

Open in new window

0
Comment
Question by:seopti
  • 3
4 Comments
 

Author Comment

by:seopti
ID: 24806105
In my server error.log I'm seeing:

PHP Warning:  mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/htdocs/users/picksoft/picksoft/localheavyconstruction.com/import/importus.php on line 7
0
 
LVL 27

Expert Comment

by:yodercm
ID: 24806232
Probably because you need to replace 'username' and 'password' with the REAL username and password to your database.

0
 

Author Comment

by:seopti
ID: 24806309
This is just an example, of course I have replaced them on the server.
0
 

Accepted Solution

by:
seopti earned 0 total points
ID: 24806629
Solved.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question