-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
What database platform? Whether the DB is hosted locally or remotely, you should still be able to access it using the same/normal method. In-fact it's pretty common for a hosting provider to host the database remotely on a different server.
-
By that is means it's more resource heavy; PHP has to check if the file has already been included first. You're never going to experience performance issues based on that though unless you're talking about a system with thousands of simultaneous requests, or thousands of unique included files. Nit picking if you ask me. An optimized solution though would be to design your application in a way that you know at any point whether or not the file will have been included, and so you're able to just use require with the knowledge you won't be including something multiple times.
-
Dependant on the kind of images in question, if you just ask the owner they may give you permission.
-
How to Limit number of character in each line in textarea
Adam replied to PhpxZ's topic in PHP Coding Help
That only affects the visual appearance, it has no control over the limit of characters. -- As explained in your other thread about this, it will need to be done using JS. You'll also notice there's not a lot of help about this as it's not going to be easy to achieve. Validating the entry shouldn't be difficult (split() the string by "\n" and check the length() of the array and length() of each value), but it's placing the cursor on the next line when it reaches the 8th character will be tricky. JS has little standards when it comes to cursor objects, so making it all cross-browser will be a challenge too. Have you considered an alternative? What about a series of 4 text inputs with the maxlength attribute set to 8 on each, and the name set as an array (i.e. <input type="text" name="text[]" (...)). Then on the keyup event for each, check the length of the input; if it's 8 characters long set focus to the next input. In the handling PHP if you need the text as a single string, you can just implode the array with "\n" as the delimiter. -
Javascript Guru Need - How to Select all instances of same CSS class?
Adam replied to soma56's topic in Javascript Help
http://javascript.about.com/library/bldom08.htm Take note of the comments about getElementsByClassName() not being a standard. Certain browsers do offer it by default, but you can't rely on it to be cross browser that way. -
Remove the "@" before the fsockopen call and see if it's generating any errors.
-
Just move the call to your function under the actual function: <?php function GetServerStatus($site, $port) { $fp = @fsockopen($site, $port, $errno, $errstr, 2); if (!$fp) { $imagepath="off.png"; //OFFLINE IMAGE LINK! $image=imagecreatefrompng($imagepath); header('Content-Type: image/png'); imagepng($image); } else { //ONLINE Status $imagepath="on.png"; //ONLINE IMAGE LINK! $image=imagecreatefrompng($imagepath); header('Content-Type: image/png'); imagepng($image); } } $status = GetServerStatus('24.68.198.193',43594); // IP or Hostname Goes Here ?>
-
It's just a browser feature, there's nothing in-place on the website to control that.
-
Well, they were amazing! Absolutely fantastic. The more I hear their new album the more I grow to like it too. Shame I lost my phone / had it pinched on the night!
-
So you posted in the 'PHP coding help' section? Okay then, well you can still use regex: if (yourDate.match(/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-9]{4}$/)) { // valid date }
-
Given the forum this is posted in, I'm going to assume he means PHP.
-
You could use regex: if (preg_match('/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-9]{4}$/', $date)) { echo 'valid date: ' . $date; }
-
Whilst it may make it easier, perhaps learning a bit more of the 'internal' stuff is good for a solid understanding.
-
How are you sending the email, what are headers are you sending?
-
You need to call the function after you define it.
-
Why can't you generate the final file name for the uploaded file within your first script (where it's actually uploaded), and store it within a session variable for use in the second script?
-
Is there a reason why it has to be done over multiple steps like this?
-
As hinted in the edit, you need to change $comments to $_POST['comments'] as in the previous conditions.
-
No problem. Could you post the code as you have it now? Tested separately the preg_match() works fine.
-
Sorry I edited my post a little later, have you seen it?
-
You're accessing an array within the string; wrap each reference in curly brackets {} .. example: VALUES ({$_POST['CustomerID']}, (..)
-
@myrddinwylt Why is that method of evaluating if the string is empty, better than the function actually designed for it? Plus if you look at the regexp he's already performing a check to make sure there's no spaces, so the trim() call's redundant. @chris_161 Use empty() as you were.. ereg however is now deprecated, you should be using preg_match: else if (!preg_match('/^[A-Za-z0-9_-]+$/', $comments)) { $errors[] = 'comments contains invalid characters'; } Edit: where are you defining $comments? On the previous line you're using $_POST['comments'] ..
-
Super global refers to the scope of the variable, meaning that it's available globally throughout the code without needing to pass it to a function or class method (or anywhere you'd be in a different scope to the main application flow) in order to access it. By request I meant a request to the web server where the PHP is then interpreted. That instance of PHP stores what it needs in temporary memory, then the garbage collector will remove it after. It's the same with files you upload to the web server, originally they're stored in a temporary directory and then removed after. If you wish to do something with the file you need to do it there and then; it won't be available on the next request. Session variables can be used to store data you wish to share over an entire session for a particular user, or failing that yes; you'll need to copy the image to your own temporary dir that isn't cleaned up after each request. Can't you just do what you want with the file originally though instead of requiring a different page to call the right action? Also by the way, whether there's visible output or not, response headers are still sent to the browser.
-
$_FILES is a super global yes, but it's only available to that particular request. Once PHP has processed the code and sent the output to the browser, the array is removed from memory along with the temporary file you uploaded.