TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-29-2009, 06:50 PM   #1 (permalink)
The Visitor
 
Join Date: Sep 2009
Posts: 4
Thanks: 3
ilangostl is on a distinguished road
Default 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">&nbsp;</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">&nbsp;</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>

Last edited by ilangostl : 09-29-2009 at 06:51 PM. Reason: wanted to edit the subject line
ilangostl is offline  
Reply With Quote
Old 09-29-2009, 09:50 PM   #2 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

It seems that the permissions for that file are set to make it not readable.
__________________
My Site
adamdecaf is offline  
Reply With Quote
The Following User Says Thank You to adamdecaf For This Useful Post:
ilangostl (09-29-2009)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Simple Currency Converter with Automatic Symbols Wildhoney General 11 03-16-2010 05:22 PM
help on making my own crawler webtuto General 16 08-08-2009 08:55 AM
Warning: mkdir() [function.mkdir]: Result too large Orc General 3 06-03-2008 07:33 AM
exporting mysql db to excel sarmenhb Absolute Beginners 8 06-01-2008 06:07 PM
Warning: fread(): supplied argument is not a valid stream resource sarmenhb General 7 04-23-2008 08:48 AM


All times are GMT. The time now is 03:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design