-
Posts
1,469 -
Joined
-
Last visited
-
Days Won
12
Everything posted by CroNiX
-
It would probably be helpful for you to create 3 individual files, create.php, edit.php and delete.php and put the relevant code in each. Each file would contain the code necessary to perform the indicated function, including displaying the form, submitting the form, processing the form data, and the appropriate database action. You need to be able to actually test this stuff and if all code is in a single file, you can't easily do that, at least the way you are doing it.
-
session_start() needs to be at the very top of all of your pages, or else the session data won't be available to that page/script.
-
Yes, see my comment about the WHERE clause. Also about the missing variables.
-
I really don't understand what you are doing. You are doing an insert, followed by an update, followed by a delete statement. Whats the purpose? You are inserting/updating data, which doesn't seem to exist. Where are your $rosterid, $staffid, $date, $starttime, $endtime variables coming from that you are inserting/updating? Also, when updating or deleting, you usually have a WHERE clause, or else it might update/delete ALL rows in your table. DELETE from table WHERE field = some_value; UPDATE table SET field1 = value1, field2 = value2 WHERE field = some_value; Where I am saying "field = some_value"..."field" is usually an ID field, and "some_value" is the actual ID
-
I would use requinix' suggestion of just creating a blank file, and just use filemtime() to determine when the file was created. No need to store the timestamp as the filesystem does that automatically when a file is created/changed. It's also easier to implement and shorter code as well.
-
No, you removed 2 of the s's, but didn't replace them. Now it thinks there are only 3 parameters but your sending 5. Should probably be 'iisss' (first 2 fields will be integers, last 3 will be strings)
-
Also you are telling your bind that all the data fields are strings ('sssss'): $smt->bind_param('sssss', $rosterid, $staffid,$date, $starttime, $endtime); Most likely rosterid and staffid are probably integers.
-
No. You do NOT want to use mysqli_real_escape_string() WITH bound query parameters as they automatically get escaped in the binding. By manually doing it, it's being escaped 2x which can add unwanted things to your db. Also what's this doing? $db->query($sql); You don't have $sql at the point when you perform that query. Doesn't look like you want that line at all.
-
Photoshop is just an image editor. It doesn't produce HTML. You can use that image as a button, or the background for an <a> tag or whatever you are trying to use it for using CSS.
-
Try using a full system filepath (not url) to the image. '/home/user/www/images/imagename.jpg' or whatever the full path is.
-
Should have been (left the .com out) $mailbox = "{mail.thedomain.com:993/novalidate-cert/ssl}INBOX"; //use the actual mail domain/ssl port, ignore self signed cert, use SSL, open "INBOX"
-
Also, if you want, you can process these in real time instead of a cron job by creating a .forward file in the root of the mailbox and pipe the email to a script to process it. Whenever a new mail hits the mailbox, it will automatically be forwarded to the script. Personally I just use it to alert the script that a new mail hit the box and then use imap functions to retrieve like you are instead of reading the file from STDIN, since it's easier to handle attachments, etc via imap functions. Google "php pipe email to script" for more info. I just use \user-domain.com |/home/user/public_html/process_mail.php The first line tells it to deliver to the mailbox normally instead of ONLY forwarding the email (user-domain.com = user@domain.com). This leaves the email intact in the box in case something happens with our processing...then we still have the original. The 2nd line tells it to "pipe" the email to the /home/user/public_html/process_mail.php script, which has all of the imap code to retrieve the email, parse it and send it to our CRM for further processing.
-
Also, try putting enctype="multipart/form-data" in the <form> instead of <input>
-
As with most things, there are examples in the user guide: http://php.net/manual/en/features.file-upload.php
-
It's also not good to rely on checking the image extension to tell what kind of file it is. What if I just renamed "dangerous_script.php" to "pretty_picture.jpg" and uploaded it to your server? Since you just check to see if "jpg" is the file extension, it will accept it.
-
It's $_FILES, not $FILE. It's a superglobal, just like $_SERVER, $_GET, $_POST, etc
-
You need to open like: $mailbox = "{mail.thedomain:993/novalidate-cert/ssl}INBOX"; //use the actual mail domain/ssl port, ignore self signed cert, use SSL, open "INBOX" $user = 'user@thedomain.com'; //email user $password = 'password'; //email users password $mbox = imap_open($mailbox, $user, $password); //connect
-
How do you detect the outside scope of a block?
CroNiX replied to Monkuar's topic in PHP Coding Help
Maybe array_intersect()? -
http://www.sitepoint.com/stress-test-php-app-apachebench/
-
It won't necessarily halt and crash when running in a browser. It depends on what your max_execution_time is set for in your php.ini. PHP being executed via the CLI can run forever by default (can also be overridden) as it has a (default) value of 0 for max_execution_time which means it can run forever and not time out. And just because something is running forever doesn't mean it takes more memory or cpu power to process what's going on. It depends on "what IS going on". for(x = 0; x < 10000000000; $x++) { echo "$x<br>"; sleep(100); } The above will run for a very long time, and sleep for 100 seconds in between cycles. Just because it's running for a long time doesn't mean it will take a lot of CPU. Now if you had a TON of code within the for() loop, and it was doing a lot of complex things, then it would require a lot more cpu power and RAM as it's doing a lot more.
-
How to get rid of .html file when echo out images from folder
CroNiX replied to IamTomCat's topic in PHP Coding Help
//does this file contain "html" as the last 4 characters? if (strtolower(substr($dirname, -4)) != 'html') { //this isn't a file with a html extension } Further, you can use glob to ONLY get files that have certain file extensions by using the GLOB_BRACE flag, so it wouldn't grab the html file to begin with. foreach(glob($selected_dir . DIRECTORY_SEPARATOR . '*.{jpg,png}', GLOB_BRACE) as $dirname) //will only get files with .jpg and .png -
Not sure what you mean by "4kilobytes of cpu power". kilobytes is a size of data, not a measurement of cpu power. 4% of cpu power makes sense. Meaning it took 4% of your total cpu to execute the php script. It doesn't take much cpu to execute a script, unless it's really complex and a lot of code.
-
array(1,2,3,4) and [1,2,3,4] are the same thing, if you are using PHP >= 5.4, which added the [] shorthand syntax for array(). Just like you can do foreach([1,2,3,4] as $number) and $numbers = [1,2,3,4]; foreach($numbers as $number) and foreach(array(1,2,3,4) as $number) and $numbers = array(1,2,3,4); foreach($numbers as $number) They're all equivalent
-
/cronix smacks requinix with a large trout lol, n1