-
Posts
1,041 -
Joined
-
Last visited
-
Days Won
17
Everything posted by gw1500se
-
Did you check your httpd log? Do you have all error reporting turned on? I'm guessing that the path in the include is wrong. error_reporting(E_ALL);
-
php Clickable phone number from mysql fetch data
gw1500se replied to nishanperera's topic in PHP Coding Help
What do you want it to do when clicked? You can either make is a link (<a> tag) or a button (<button> tag). In both cases you need to put the table in a form. -
You don't say what data type '$columnValue' is so I am assuming it is int. $table .= strval($columnValue);
-
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
That is what is in $_FILES['userfile']? If so then that means it contains an empty array (I didn't know it would do that). I suggest you change the logic a bit and check for errors. Remove the 'if' outside the 'foreach' and try this: foreach($_FILES['userfile']['name'] as $name) { if ($name['error']==0) { /* handle file */ } else { /* handle error */ } } You will need to decide how to handle the errors. Oddly, I think code 4 means duplicate file names. -
Yes, for Linux use cron and for Windows use task scheduler.
-
Did you look at the httpd error log?
-
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
That means there is something in the array. See what it there with this: echo "<pre>"; print_r($_FILES['userfile']); echo "</pre>"; -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
My bad. The first error is a warning/notice. You did not specify the Content-type correctly but it assumed the correct value. As for the 2nd error it looks like you are running PHP version 5.1 or earlier. Version 5.2 or better has json built in. Your version does not and you will need to install php-pecl-json. -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
The 2nd error is because the first failed. You don't show what '$context' contains but I'm guessing you only need 1 parameter, the file path. -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
if (is_array($_FILES['userfile'])) { foreach($_FILES['userfile']['name'] as $name) { $type = pathinfo($name, PATHINFO_EXTENSION); if(!in_array($type, $allowed)) die("Error: Only jpg, jpeg, gif and png files are allowed.-".$type); } } } -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
I mean do the other $msg errors work? -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
A good IDE will help you with your indents which are still messed up making it difficult to read. I don't see where you initialize '$msg' to an empty string and I am not sure what happens when you concatenate to a variable that does not yet exist. Poor programming practice even if that works. Do the other errors show up? -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
It looks like you are missing one 'if' and have an extra 'else'. Where are you checking the file type? You need to practice good programming practice by properly indenting your code. if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) { if ($mail->addAttachment($uploadfile, $filename)) { /* You need to check for the desired file types here berfore you add it to the attach array */ $attachmentNames[] = $_FILES['userfile']['name'][$ct]; } else { $msg .= 'Failed to attach file ' . $_FILES['userfile']['name'][$ct]; } } else { $msg .= 'Failed to move file to ' . $uploadfile; } /* Where is the if for the next else, which doesn't belong here anyway? */ -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
??? You do it with PHP. Check the file type and if is it unacceptable do not attach it. -
only allow jpg and png file extensions phpmailer
gw1500se replied to ianhaney's topic in PHP Coding Help
Use explode with '.' on the file path, then look at the last array element and that is the file type. -
First please use the code icon (<>) for your code and specify PHP and HTML as appropriate. What you omitted from your post is what error are you getting or what are you getting that is different from what you expect?
-
You don't show any code or error. Is the slash stored in the database as the string '/' or as '/'? If you are using regex as the search string you need to escape the slash (i.e. \/).
-
You needed to escape the " as I said in my correction.
-
Correction: Add \ in front of the " that do not start or end the echo.
-
Your 'if' makes no sense. 'if' is a PHP statement yet you are starting PHP after the if. Also you are testing the result of 'echo' not the value of $chk. I am guessing but I think you want: <?php if ($chk == 0) { ?> . . . <?php } else { ?> . . . <?php } ?> That having been said, it is a poor way to program. You should do something more like: <?php if ($chk} == 0) { echo " <div class="container"> <div class="row" style="color:red"> <br><br><br><br><br><br> <center>Database Update Failed</center> </div> </div>" } else { echo " <div class="container"> <div class="row"> <br><br><br><br><br><br> <center>Database Updated</center> </div> </div>" } ?>
-
Detect codepage to use, read it from system? (for ZIP files)
gw1500se replied to Sonnich's topic in PHP Coding Help
Will utf8-decode help?