Jump to content

[SOLVED] file_get_contents help


EP

Recommended Posts

Hey guys.  I need a little help here.

 

I have a program that spits out a text file with a complete INSERT query to insert data into a mysql database.  After the text file is updated, this php file is supposed to be run using GET instead of POST so it can take the new info from the file and run the command.

 

I tried to call the file up in a web browser and checked the database but it was not updated.

 

Here is the code:

<?

mysql_connect("localhost", "root", "password");
mysql_select_db("database");

$file=file_get_contents("output_file.txt");


mysql_query($file);


mysql_close();
?>

 

 

The final mysql_query result should be something like...

mysql_query("INSERT INTO table VALUES ('value1', 'value2', 'value3', 'value4')");

 

..because that's what the text file contains.

 

 

I don't understand what I am doing wrong.  Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/114821-solved-file_get_contents-help/
Share on other sites

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.