Jump to content

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'


devans725

Recommended Posts

I feel like I have tried everything, I can get it to work from the command line, cannot get script to run.  Any help is appreciated. 

 

<?php

exec "select * from employee_dat where gross = \"38462\"" | mysql -uSername -pAssword hello_W2 > w2.txt;

?>[/code

I am accessing mysql that way because when I connected with mysql_connect and mysql_select_db, I would use INTO OUTFILE in my sql statement, and it would always return Acess Denied, using Password=yes.  I played with permissions for a couple of days and decided that this was something that my ISP wouldn't allow from what I found researching the error, I could be wrong, hope I am.  That is when I decided to use the one line echo statement.  This is the code I was trying to use before:

<?php
$con = mysql_connect("localhost","User","Password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("database_W2", $con);

$state = $_POST["state"];
$gross = $_POST["gross"];

$result = mysql_query("SELECT * INTO OUTFILE '/share/wdat.csv' FROM employee_dat WHERE gross = '$gross' AND state = '$state';") or die(mysql_error());

echo "\nSQL Statement = $result <br>"; 

mysql_close($con);
?>

 

I tried what you suggested except I used echo instead of exec.  I didn't get the results I was looking for, it just displayed my statement, should I use exec? echo works at the command line?  Thanks for the reply.  Any further suggestions will be appreciated.  Ultimately I just want to query the database and write the info to a text or CSV file.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.