I started a question about two weeks ago and have finally gotten a chance to work it. I was unable to get the solution, so, I am starting another one and whoever gets my solution fixed, gets 500 from this one and 500 from the first one.
I am trying to get the php command line that will import a text file full of sql commands.
I was given a few solutions and have tested them.
I am still unable to get this to work. Here is the php script that I have so far....
<?php
$link = mysql_connect('localhost',
'*****', '*****');
if (!$link) {die('Could not connect: ' . mysql_error());}
$db_selected = mysql_select_db('newstoren
eon');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());}
echo 'Connected successfully';
mysql_close($link);
?>
When I run this script as a web page, it connects correctly and echos Connected successfully. With that, I know that I am successfully connecting to the database. When I add the following line to the script right after the echo, the script still runs and does not show an error.
exec('mysql -B < /var/www/html/store/files/
test.txt')
;
I appears to run, but it does not change the database.
So I then added the following line right below the exec line above...
exec ("wc -l /var/www/html/store/files/
test.txt")
;
When I run the script now, it still does not show that it is actually accessing the test.txt file.
So, question number 1 is this....
Do I need to go all the way up to the root level for the absolute address? i.e.(/var/www/html/store/f
iles/)
Or do I only put the lower levels from the script level down? i.e.(/store/files/)
Next, do I have my scripting incorrect and that is why it is not accessing the file?
Ok, the test.txt file consists of the following line only......
update `pricing` set `price` = '99.99' where `priceid` = '19302' LIMIT 1 ;
So, the script below...
<?php
$link = mysql_connect('localhost',
'xcart', 'tracx');
if (!$link) {die('Could not connect: ' . mysql_error());}
$db_selected = mysql_select_db('newstoren
eon');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());}
echo 'Connected successfully';
exec('mysql -B < /var/www/html/store/files/
test.txt')
;
mysql_close($link);
?>
is supposed to execute the /var/www/html/store/files/
test.txt file that contains the following data...
update `xcart_pricing` set `price` = '99.99' where `priceid` = '19302' LIMIT 1 ;
What am I doing wrong? If I can get the .php script to execute the sql command in the test.txt file, I can adapt everything from there and actually be complete with my data automation. I have several hundred thousand sql commands to run, but can complete it if I could only get this 1 single line of sql to run.
The .php file is located in my domain root.......
www.***************.com/test.php which exists as /var/www/html/test.php
The text file it is supposed to execute is at the following address..........
www.**************.com/store/files/test.txt which really exists as /var/www/html/store/files/
test.txt
Please help ASAP so I can shut my brain off for a few hours after I finish this automation.
Start Free Trial