Hi,
I'm really stuck with a problem and I've been at this for days trying to get
this sorted but I just have to call for help.
Basically I have a form where I can upload .doc's only to the server. I have a good few conditional statements on the page
and they all work fine when checking for any incorrect uploads such as
images or anything that is not a .doc. The problem arises when in fact the
correct file passes all the validation and goes on to upload and here is
here I get the following errors.
Warning: fopen(log.txt): failed to open stream: Permission denied in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 93
Warning: fwrite(): supplied argument is not a valid stream resource in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 96
Warning: fclose(): supplied argument is not a valid stream resource in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 97
Warning: in_array(): Wrong datatype for second argument in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 107
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 168
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 169
If I remove the validation including the insert function from this:
if (isset($_POST['wordDetails']) && !empty($_POST['wordDetails'])) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
//$wordDetails here added by Brian
//proceed with insert into db once all tests are passed.
$insertSQL = sprintf("INSERT INTO word (wordName, wordDetails) VALUES
(%s, %s)",
GetSQLValueString($_FILES['userfile']['name'],
"text"),
GetSQLValueString($_POST['wordDetails'], "text"));
mysql_select_db($database_johnston, $johnston);
$Result1 = mysql_query($insertSQL, $johnston) or die(mysql_error());
}
To this:
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
It will upload ok but obviously the validation has gone out the window!
Now what's really frustrating me to death is that if I test this locally on my PC and
that's including all the validation it works perfectly with no errors at all
but it's only when I upload this to the server it throws a wobbly.
I have tried moving this particular conditional statement and tried re
scripting the validation to other places and I'll refrain from posting any
more code at this time to show my many attempts but if anybody can tell me
why the errors are happening on the live server and not locally I'd be most
thankful.
I have the entire code of the page here with the relevant section
highlighted (scroll down) in the hope that this issue can be fixed.
I appreciate that there is lots of code but I feel that it's best to show it
all rather than too many snippets.
Thanks
Brian
www.ahamay.com/validation.php
I'm really stuck with a problem and I've been at this for days trying to get
this sorted but I just have to call for help.
Basically I have a form where I can upload .doc's only to the server. I have a good few conditional statements on the page
and they all work fine when checking for any incorrect uploads such as
images or anything that is not a .doc. The problem arises when in fact the
correct file passes all the validation and goes on to upload and here is
here I get the following errors.
Warning: fopen(log.txt): failed to open stream: Permission denied in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 93
Warning: fwrite(): supplied argument is not a valid stream resource in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 96
Warning: fclose(): supplied argument is not a valid stream resource in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 97
Warning: in_array(): Wrong datatype for second argument in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 107
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 168
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
in
/home/johnston/domains/fergusjohnston.com/public_html/admin_word_update5.php
on line 169
If I remove the validation including the insert function from this:
if (isset($_POST['wordDetails']) && !empty($_POST['wordDetails'])) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
//$wordDetails here added by Brian
//proceed with insert into db once all tests are passed.
$insertSQL = sprintf("INSERT INTO word (wordName, wordDetails) VALUES
(%s, %s)",
GetSQLValueString($_FILES['userfile']['name'],
"text"),
GetSQLValueString($_POST['wordDetails'], "text"));
mysql_select_db($database_johnston, $johnston);
$Result1 = mysql_query($insertSQL, $johnston) or die(mysql_error());
}
To this:
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_path = $upload_dir.$file_name;
It will upload ok but obviously the validation has gone out the window!
Now what's really frustrating me to death is that if I test this locally on my PC and
that's including all the validation it works perfectly with no errors at all
but it's only when I upload this to the server it throws a wobbly.
I have tried moving this particular conditional statement and tried re
scripting the validation to other places and I'll refrain from posting any
more code at this time to show my many attempts but if anybody can tell me
why the errors are happening on the live server and not locally I'd be most
thankful.
I have the entire code of the page here with the relevant section
highlighted (scroll down) in the hope that this issue can be fixed.
I appreciate that there is lots of code but I feel that it's best to show it
all rather than too many snippets.
Thanks
Brian
www.ahamay.com/validation.php