Solved

MySQL connection problem

Posted on 2009-07-08
4
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Cornelia Yoder
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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