devans725 Posted March 19, 2008 Share Posted March 19, 2008 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 Link to comment https://forums.phpfreaks.com/topic/96990-parse-error-syntax-error-unexpected-t_string-expecting-or/ Share on other sites More sharing options...
devans725 Posted March 20, 2008 Author Share Posted March 20, 2008 *bump* I'm using echo not exec Link to comment https://forums.phpfreaks.com/topic/96990-parse-error-syntax-error-unexpected-t_string-expecting-or/#findComment-496922 Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 first question is why are you accessing mysql that way? but if that's what you're after, try this: <?php exec "select * from employee_dat where gross = '38462' | mysql -uSername -pAssword hello_W2 > w2.txt"; ?> Link to comment https://forums.phpfreaks.com/topic/96990-parse-error-syntax-error-unexpected-t_string-expecting-or/#findComment-496929 Share on other sites More sharing options...
devans725 Posted March 20, 2008 Author Share Posted March 20, 2008 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. Link to comment https://forums.phpfreaks.com/topic/96990-parse-error-syntax-error-unexpected-t_string-expecting-or/#findComment-496972 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.