Advertisement

08.22.2008 at 12:23PM PDT, ID: 23671297
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

import text file full of sql commands using php

Asked by THE_HORSEPOWERSHOP in PHP and Databases, MySQL Server

Tags:

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('newstoreneon');
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/files/)
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('newstoreneon');
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
[+][-]08.22.2008 at 01:03PM PDT, ID: 22293631

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.22.2008 at 01:20PM PDT, ID: 22293788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.22.2008 at 01:34PM PDT, ID: 22293881

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.22.2008 at 01:36PM PDT, ID: 22293894

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.22.2008 at 01:55PM PDT, ID: 22294040

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.22.2008 at 02:19PM PDT, ID: 22294174

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.01.2008 at 04:55AM PDT, ID: 22359423

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, MySQL Server
Tags: php mysql
Sign Up Now!
Solution Provided By: bportlock
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.01.2008 at 04:57AM PDT, ID: 22359432

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.01.2008 at 05:39AM PDT, ID: 22359646

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.01.2008 at 08:36PM PDT, ID: 22364042

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.02.2008 at 01:59AM PDT, ID: 22365280

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628