Jump to content

What's wrong with this?


ok

Recommended Posts

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..................................!!!

Link to comment
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.