Jump to content

file_get_conntent error


trpplayer79

Recommended Posts

what can be the problem ifi get this error:

Warning: file_get_contents() [function.file-get-contents]: Unable to access I:\\website muziek\\test6.sql in /customers/harmonierosmeer.be/harmonierosmeer.be/httpd.www/admin/update.php on line 36

Warning: file_get_contents(I:\\website muziek\\test6.sql) [function.file-get-contents]: failed to open stream: No such file or directory in /customers/harmonierosmeer.be/harmonierosmeer.be/httpd.www/admin/update.php on line 36

 

the code i use is this:

<?php
if(isset($_GET["upgrade"]))
{
   $upgr=$_GET["upgrade"];
}
else
{
   $upgr="select";
}
if ($upgr=="select")
{?>
<center>
<H2>This page is to upgrade the "agenda" by using a SQL export!</H2>
<H3>the export needs to be created with "MdbToMySQL.exe" from "zebradb"</h3>
<form method="POST" name="updaten" action="update.php?upgrade=upgrade">
<input type="file" name="file2upl" size="36"><br><br>
<input type="submit" value="Import">
</form>
</center>
<?}
if ($upgr=="upgrade")
{
$connect = mysqli_connect('localhost', 'harmonierosmeer', 'pebttaWL', 'harmonierosmeer',"3307");
if(mysqli_connect_errno())
{
    trigger_error('Error in connection: '.$connect->error);
}
$sql = file_get_contents($_POST['file2upl']);
if (mysqli_multi_query($connect, $sql)) 
{
    do {
        /* store first result set */
        if ($result = mysqli_store_result($connect)) 
	{
            while ($row = mysqli_fetch_row($result)) 
		{ 
		    printf("%s\n", $row[0]);
            }
            mysqli_free_result($result);
        }
        /* print divider */
	if (mysqli_more_results($connect)) 
	{
            print("--D-I-S--");
        }
    } while (mysqli_next_result($connect));
}
?> 
<br>--D-I-S-- stands for Data Instert Successfull.<br>

Link to comment
https://forums.phpfreaks.com/topic/69783-file_get_conntent-error/
Share on other sites

Hey there,

 

from the looks of it you have a few issues to resolve.

 

1. you need to use the $_FILES array to grab the data from your file

ref: http://us2.php.net/manual/en/features.file-upload.php#features.file-upload.post-method

 

2. you need to pass an sql query (maybe your form is uploading that? if so you should make darn well sure the query is what you it should be, else someone can just have their way with your db.

ref: http://us2.php.net/mysqli_multi_query

 

3. if you are posting data to a process page, don't pass data with on the query string to that page.


<!-- this is works, but isn't consistent -->
<form method="POST" name="updaten" action="update.php?upgrade=upgrade">

<!-- this is consistent and harder for users to change values -->
<form method="POST" name="updaten" action="update.php">
<input type="hidden" name="upgrade" value="upgrade"/>

<?php 
// then in your process page

if ( isset($_POST["upgrade"]) ) {
   $upgr=$_GET["upgrade"];
} else {
   $upgr="select";
}
?>

 

 

good luck

 

Dear,

 

this code works on my offline web server but not on the online server.

read the following topic where u have more information about what I want.

http://www.phpfreaks.com/forums/index.php/topic,158000.0.html

 

I don't want to upload the file, i only whant to read the 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.