![]() |
Warning:
My goal is to learn PHP. At the same time I am trying to run a sample PHP project because I have to implement something in PHP in a few days and I have never learned PHP before.
I plan to learn PHP using this forum and a textbook from scratch. Right now, I would be very thankful if I can get help solving the issue in the sample project. The error I am getting is: Warning: fopen(minus.sql) [function.fopen]: failed to open stream: Permission denied in /Users/Samantha/Sites/samplesite2/Installer/index.php on line 40 Warning: fread(): supplied argument is not a valid stream resource in /Users/Samantha/Sites/samplesite2/Installer/index.php on line 41 The file where the error is emanating from is below: <?php $sqlErrorText = ''; $sqlErrorCode = 0; $sqlStmt = ''; $sqlFileToExecute = 'minus.sql'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Application Installer</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="caption">Database Installer</div> <div id="icon"> </div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="dbdata"> <table width="100%"> <tr><td>Hostname:</td><td><input class="text" name="hostname" type="text" size="20" value="localhost" /></td></tr> <tr><td>Username:</td><td> <input class="text" name="username" type="text" size="20" value="root" /></td></tr> <tr><td>Password:</td><td> <input class="text" name="password" type="password" size="20" value="riley123" /></td></tr> <tr><td>Database Name:</td><td> <input class="text" name="Database" type="text" size="20" value="mynewdatabase" /></td></tr> <tr><td align="center" colspan="2"><br/><input class="text" type="submit" name="submitBtn" value="Install" /></td></tr> </table> </form> <?php if (isset($_POST['submitBtn'])){ $host = isset($_POST['hostname']) ? $_POST['hostname'] : ''; $user = isset($_POST['username']) ? $_POST['username'] : ''; $pass = isset($_POST['password']) ? $_POST['password'] : ''; $dbname = isset($_POST['Database']) ? $_POST['Database'] : ''; $con = mysql_connect($host,$user,$pass); $msqlcon = mysql_select_db($dbname); if ($con !== false){ // Load and explode the sql file $f = fopen($sqlFileToExecute,"r+"); $sqlFile = fread($f,filesize($sqlFileToExecute)); $sqlArray = explode(';',$sqlFile); //Process the sql file by statements foreach ($sqlArray as $stmt) { if (strlen($stmt)>3){ $result = mysql_query($stmt); if (!$result){ $sqlErrorCode = mysql_errno(); $sqlErrorText = mysql_error(); $sqlStmt = $stmt; break; } } } } ?> <div class="caption">RESULT:</div> <div id="icon2"> </div> <div id="result"> <table width="100%"> <?php if ($sqlErrorCode == 0){ echo "<tr><td>Installation was finished succesfully!</td></tr>"; } else { echo "<tr><td>An error occured during installation!</td></tr>"; echo "<tr><td>Error code: $sqlErrorCode</td></tr>"; echo "<tr><td>Error text: $sqlErrorText</td></tr>"; echo "<tr><td>Statement:<br/> $sqlStmt</td></tr>"; } ?> </table> </div> <?php } ?> <div id="source">Database Installer 1.0</div> </div> </body> |
It seems that the permissions for that file are set to make it not readable.
|
| All times are GMT. The time now is 01:24 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0