-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
2.5 hours. Both of them are 30 minutes beyond what you expected. Where are you seeing the original and result values? And a totally random question that will probably lead nowhere, what timezone are you and your server in? [edit] And on that note, what happens if you select `end` without any DATE_ADDing?
-
XML does not contain styles. Embed the data in the XML any way you see fit, then write the XSLT so that it uses the right styles. Consider all the information the XSLT will need to use to output the right HTML: the raw text, colspans, CSS attributes and values...
-
validation on textarea to allow only characters no numbers!
requinix replied to saravanataee's topic in Javascript Help
Take a quick look at documentation for regular expressions in Javascript. The MDN is a good place to check for examples. Once you know about the .test() method you can use /^[a-zA-Z]{0,100}$/ That will also validate the length.- 3 replies
-
- validation
- textarea
-
(and 1 more)
Tagged with:
-
Checking db for usernames that already exist
requinix replied to wright67uk's topic in PHP Coding Help
"SELECT * FROM registration WHERE uname = ".$uname." OR email = ".$email." LIMIT 1" You forgot the quotes. -
I think you're having problems understanding causality... What's the code?
-
The problem with this code is not arrays, it's that you're trying to get a directory listing of some place on the internet. $dir has to be a file path, not a URL.
- 9 replies
-
- read directory
- explode
-
(and 1 more)
Tagged with:
-
Simple best-practice idea to prevent sql injections
requinix replied to tibberous's topic in Miscellaneous
- filter_var is a more powerful version of the req() and ireq() you made. - Besides unescaped() you could just as easily search for code using $_REQUEST directly and fix that. -
1. Look at the link jcbones gave you for the foreach construct. That pages tells you exactly what it does and how to use it. 2. Compare your strlen() code with mine. My version is everything up to the wildcard: no wildcard, no extension. 3. Also look at the manual page for substr. It takes three arguments, not four. The third argument needs to be a negative number. Here's why. substr() extracts a piece of a string, starting at one place and going forward to another place. The filename has three parts to it: the initial part with the path and the "cat-par", the name that you want to extract from it, and everything else after it (ie, the extension). Using strlen() you know the length of the first part so that's where substr() should start; using -4 for the third argument tells it to from the starting point up to four characters from the end. Four because the extension - the third part - is four characters long. 4. Now that you have $pieces you need to do something with it. It will be an array so you could foreach over it. Or you could do something more clever. It depends how the "print discrete words under image" needs to work for your existing code.
- 9 replies
-
- read directory
- explode
-
(and 1 more)
Tagged with:
-
#1 and #2 can be done with one call to glob(). $title = /* current page slug */; $files = glob("uploads/cat-{$title}-*.jpg"); For #3 you can substr() for the middle portion, explode() for the pieces, and ucfirst() for the capitalization. // for each $file in $files { $filename = substr($file, strlen("uploads/cat-{$title}-"), -4); $pieces = array_map("ucfirst", explode("-", $filename)); // } #4 is a loop and #5 is making a link to $filename.
- 9 replies
-
- read directory
- explode
-
(and 1 more)
Tagged with:
-
Using PHP to tell me how many rows are in a table
requinix replied to gotornot's topic in PHP Coding Help
Are you saying that the query $qx = "select count(*) FROM products"; takes too long to execute? -
Okay, so say you try <?php $data = "hi"; ?> function displayinfo() { document.getElementById("demo").innerHTML=<?php echo $data;?>; } That will still output the same thing and will still have the same problem. It's the way you're outputting the value that's the problem, not whether it's a string or a variable or whatever. Now with that said, look at this Javascript code. document.getElementById("demo").innerHTML=hi; What do you think it will do?
-
Ah, too late to edit out your password... That code doesn't support uploading multiple images. It just doesn't. And certainly not up to 9. It may look like it's going into the database right but that's the only part that works.
-
Your PHP will output function displayinfo() { document.getElementById("demo").innerHTML=hi; } Does that look correct?
-
But what about the rest of the data? What "title"s match up with what "name"s? How do you know where the new values are going?
-
Can someone explain whats happening to $e in this
requinix replied to Kiwiguy51's topic in Third Party Scripts
That should be one single call to rawurlencode. $button_url = 'Location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='. $paypal2.'&item_name='.$product_name2.'&item_number='.$product_id2.'&amount='.$price2.'&no_shipping=1&return='. $download_link2.'&cancel_return='.$cancel_link2.'&no_note=1¤cy_code=USD¬ify_url='.$ipn_link2.'&cpp_header_image='.$ppheader_url2; I'm not too familiar with this part of PayPal but I believe the business= is your email address, not the customer's. Separately, it looks like you're putting the notify_url for IPN in the URL you're redirecting too? That should be specified in your account instead. Exposing that location to the user is a risk to your listening code, and though it should not be a problem (because it verifies the request with PayPal) there's always the chance of a malicious user discovering an exploit in the code. I don't know how it was "turned off" so this may not be a problem. -
1a. Fix your HTML. It outputs a for every single row, and in a place where a is not allowed. Move it to before you start the table and remember to close it after.1b. Fix your HTML. The checkbox isn't closed. 2. You don't put any ID information in the form. Your code won't find it because it's not there. 3. Instead of adding it, rewrite the checkboxes to <input name="ONOFF[]" type="checkbox" value="<?php echo $row['id']; ?>" <?php if($row['hot_job'] == 'YES') { echo "checked='checked' "; } ?>/> Then // checkboxes are only sent if checked // disable everything then re-enable mysql_query("UPDATE jobs SET hot_job = 'NO'"); if (!empty($_POST["ONOFF"]) && is_array($_POST["ONOFF"])) { // sanitize $ids = array_map("intval", array_filter($_POST["ONOFF"], "is_scalar")); // update all of them at once in batches of 1000 foreach (array_chunk($ids, 1000) as $batch) { mysql_query("UPDATE jobs SET hot_job = 'YES' WHERE id IN (" . implode(", ", $batch) . ")"); } } Since you mix-and-match YES/NO with 1/0 I assume the column is an ENUM?
-
posting to https within an iframe produces error
requinix replied to CaptainChainsaw's topic in Apache HTTP Server
*.dev.com does not validate www.myserver.dev.com: the asterisk is only good for one component. -
1. On the dev machine, make sure the firewall allows inbound connections to port 80. With Windows, it might have asked you already, but look for the firewall settings and (if there isn't a rule) add one. 2. On the dev machine, grab the name of the machine and make sure your site is set up to work for that name. With Apache, the main configuration (or virtualhost if you're using that) needs either the ServerName to be the machine name or add a ServerAlias for it. And restart it. 3. On the laptop, try http://themachinename/.
-
What is the error message exactly?
-
Can someone explain whats happening to $e in this
requinix replied to Kiwiguy51's topic in Third Party Scripts
Hard to say for sure without any kind of context or explanation of what this code is about... If $e (from the URL) is any one of those values then substitute $e=$ppe. Perhaps those are for testing? -
You mean it created it as 0755? The umask will disable those bits: 0777 & ~(0022) = 0755. $oldumask = umask(0); mkdir("new", 0777); umask($oldmask); However I wouldn't change the umask at all. It's easy to forget to change it back. mkdir("new"); chmod("new", 0777);
-
inlcude php in shtml without modifying htaccess
requinix replied to toolman's topic in PHP Coding Help
a] Make a .php file include() that file. b] Edit the Apache config (main server config or virtualhost config) to parse .shtml files. c] Rename the file. Any particular reason you don't want to touch the .htaccess? Besides renaming the file, that's really the best solution. -
Instead of a loop, use XPath to grab the elements you want directly: one is a "high" and one is a "low" temperature. $high = current($xml->forecastGroup->forecast->xpath("temperatures[@class='high']")); $low = current($xml->forecastGroup->forecast->xpath("temperatures[@class='low']")); if ($high && $low) { // range is $low to $high } else if ($high) { // high of $high } else { // low of $low }
-
Try to help, but if that doesn't work then you have proof that the buyer is the one who screwed up: they reformatted it, not you. You sold them a device that was not only in perfect working order but even had some "demo" content for them to see. But really, a restore isn't working? That can fix just about any problem at the expense of losing everything stored.
-
So you want to keep the rows with the earliest "date" field? How about DELETE FROM table AS t1 JOIN ( SELECT cupID, matchno, MIN(date) AS mindate FROM table GROUP BY cupID, matchno HAVING COUNT(1) > 1 ) AS t2 ON t1.cupID = t2.cupID AND t1.matchno = t2.matchno AND t1.date > t2.mindate But you really, really should figure out where the duplicates are coming from. It's a problem. Problems are bad.