ok Posted September 12, 2008 Share Posted September 12, 2008 Hi guys. these codes below works properly, <?php include 'opendb.php'; $query = "TRUNCATE TABLE csv"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $query = "SELECT DISTINCT user_name FROM user_join"; $result = mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $i=0; while($row = mysql_fetch_array($result)){ $user[$i] = $row['user_name']; $i++; } foreach($user as $name) { $query = "SELECT * FROM user_join WHERE user_name='$name'"; $result = mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $row = mysql_fetch_array($result); $user_name = $row['user_name']; $email = $row['email']; $date_join = $row['date_join']; $name_exploded = explode(" ", $user_name); $fname = $name_exploded[0]; $lname = $name_exploded[1]; #echo "<br>fname: ". $fname ." lname ". $lname ." email: ". $email ." date: ". $date_join; $query = "INSERT INTO csv (fname, lname, email, date_join) VALUES ('$fname', '$lname', '$email', '$date_join')"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); } ?> but when i added this codes, $query = "SELECT fname, lname, email, date_join INTO OUTFILE 'csv.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' FROM csv"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); and the whole codes looks like this now below, including the wrongr codes, <?php include 'opendb.php'; $query = "TRUNCATE TABLE csv"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $query = "SELECT DISTINCT user_name FROM user_join"; $result = mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $i=0; while($row = mysql_fetch_array($result)){ $user[$i] = $row['user_name']; $i++; } foreach($user as $name) { $query = "SELECT * FROM user_join WHERE user_name='$name'"; $result = mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $row = mysql_fetch_array($result); $user_name = $row['user_name']; $email = $row['email']; $date_join = $row['date_join']; $name_exploded = explode(" ", $user_name); $fname = $name_exploded[0]; $lname = $name_exploded[1]; #echo "<br>fname: ". $fname ." lname ". $lname ." email: ". $email ." date: ". $date_join; $query = "INSERT INTO csv (fname, lname, email, date_join) VALUES ('$fname', '$lname', '$email', '$date_join')"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); } $query = "SELECT fname, lname, email, date_join INTO OUTFILE 'csv.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' FROM csv"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); ?> the error message is this, Problem with the query: SELECT fname, lname, email, date_join INTO OUTFILE 'csv.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM csv on line 38 Access denied for user 'joealex3_alex'@'localhost' (using password: YES) I'm going nuts with this. any help please. Thank you very much..................................!!! Quote Link to comment 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.