-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
If you have a bunch of arbitrary redirections with no real pattern, you may just need to generate a bunch of rewrite entries for each url (or use RewriteMap)
-
A lot of browsers (and even other software) these days does intelligent guessing as to what a file's content truly is rather than just blindly assume that it is whatever the extensions says it is. They often examine the start and/or end bytes of a file for some kind of magic sequence to indicate what content type is being dealt with. Take a random .png/.jpg/.bmp/.gif file and rename the extension to some incorrect type and open it in one of the browsers. Chances are it will still get properly interpreted because these files have header sequences that identify what content it is. Exactly when and how the browser does such guessing may vary from browser-to-browser. Some may only do it if the file type is unknown. Others may do it always. Older versions of IE used to ignore the Content-type http header and guess the content type, meaning when someone served something HTML like as Content-type: text/plain intentionally, say as an example, IE would still render the HTML. It caused much annoyance among people and was eventually fixed in the later versions.
-
If you mean it displays the HTML source rather than rendering it, I'd gather it probably just treats the file as plain text. If you mean it renders the HTML, that is fairly typical I believe. It will sniff the file contents to try and determine what it is rather than just base it on the extension. If it looks like HTML it'll get rendered as HTML. With a little experimenting it seems to base it's decision on whether the first word looks like something HTML. If so, it renders as HTML. If not, it renders as plain text.
-
Read through this "Why Interfaces?" thread on devshed for some details about both interfaces and abstract classes.
-
It could be done sure, but why not just modify announcements_current.php to generate the proper links in the first place rather than apply some JS hack?
-
-
There's no need to not use an normal auto-increment ID number in the database for such a task. Just do the conversion in PHP when you select the link data. For example, when adding a URL: $sql = 'INSERT ...'; $db->exec($sql); $id = $db->lastInsertId(); echo 'Your url is http://example.com/'.encodeId($id); ; When getting a page: $id = decodeId($_GET['id']); $sql = 'SELECT ... WHERE id=?'; $stmt = $db->prepare($sql); $stmt->execute([$id]); var_dump($stmt->fetch()); Just create two functions, one encodeId which will change an integer in to your short string, and decodeId which will change the short string back into your integer.
-
use this.href to get the value of the href attribute.
-
No, just because a domain doesn't resolve to an IP does not mean that it is available. Someone may have it registered but not pointing to anything (or only subdomains point to something). In order to check if a domain is available you need to do a whois check and see if it comes back as registered or not.
-
file_get_contents file_put_contents
-
I don't think PDO will be going anywhere like mysql_* did. PDO was designed to be just a normalized API without and specific database association. The database association is handled by whichever driver you decide to load into it. If there were another instance of something like the mysql -> mysqli switch that needed to be done, it would likely just be implemented as just a driver change, eg: //Rather than new PDO('mysql:...'); //You'd do new PDO('mysqli:...'); I simply rely on PDO for my code. I trust that it won't be needing replacing.
-
Unless you want to prevent the entire page reloading and just swap out the questions, ajax is not required. Javascript is however to trigger the submit. Just a simple onclick that calls the forms submit function is all you need. <form method="POST" action="<?php $php_self; ?> Question: True/False - The sky is blue</br> <input type='radio ' value='yes' id='answer' name='answer' onclick='this.form.submit();'> Yes</br> <input type='radio ' value='no' id='answer' name='answer' onclick='this.form.submit();'>No</br> </form>
-
If you run the download via a PHP script, you can have it update a value somewhere to indicate when it has finished sending the file. Note though that this would merely indicate that it sent the file, not that it was successfully received on the end-users machine. As for the issue of just hiding the loading icon, you may need to be a bit more descriptive of how you have things setup. It sounds like you'd need to be constantly polling the server to check the generation/download status the way you describe things right now.
-
You've gotta keep in mind the times when these things were developed. Sometimes the best way from an organizational point of view is not the best way from a speed point of view, and speed may be of greater value than organization in some instances. I remember my first PC that I got back in '98 was 233mhz processor with 32MB of RAM and a 2gig HD. On systems like that, or with less specs, storing things in a perfectly normalized manner may have taken up too much memory or processing time compared to a serialized format. Whether something is stored in a good way or a bad way is not a black-n-white line, one has to take into account how the data needs to be used, and what the requirements of the application are. (edit: I think my pc may have actually been 16mb ram out of the box, and I upgraded it to 32 after a year or so).
-
Just concatenate this.value onto the URL. Use encodeURIComponent to take care of any special characters.
-
how I make a single query for both insert and update?
kicken replied to thara's topic in PHP Coding Help
No, there is not a way to INSERT/UPDATE data and SELECT the data back out from the same query. You'd have to do a separate select query after your insert/update query. -
My guess would be they just stuff a struct value in there in binary format. Without the C/C++ code that interacts with the database, one can only guess really. You'll need to get that source and review it to know for sure what they are doing. As far as reading such a value with PHP: unpack Whether what they did is a good idea or not depends on what exactly needs to be done with the data. If they never need to search through it then something like that is fine. I've done similar with storing serialized/json_encoded arrays in a DB field when the data does not need to be searched in any way, just stored.
-
You need to access them via apache using a URL, not by just opening them directly in the browser (with file->open for example). Open your browser then go to the URL http://localhost/madlib.php and it should work, assuming you have saved your madlib.php file into the document root folder that xampp sets up.
-
No, false returns as false, and true returns as true. If you're talking about what they would be after converting them to a string (such as by echo'ing them) then false become "" (empty string) and true becomes "1". If you want to see exactly what a value is (type and contents) use var_dump($var);
-
what makes you think you can't return a boolean? Also, there's no need for the ternary operator there, you can just do: return $conn->affected_rows > 0;
-
Those strings are a sequence of hex codes, each pair of characters represents one of the original characters. You can see that the only difference between the two strings is the extra 20 at the front: 204272697474656E 4272697474656E If you check the ascii chart (Hx column) you can see that hex code 20 corresponds to a space character, meaning two of your rows have an extra space at the front of their value.
-
The main issue I've had with switching to nginx is apps with extensive use of .htaccess/mod_rewrite rules can sometimes be a pain to convert over to the proper nginx configuration. If that is not an issue for you, then nginx + php-fpm seems to be a pretty nice setup. Apache + worker mpm + php-fpm is a decent setup as well. You separate apache from PHP so static resources do not incur any overhead from PHP, and the worker mpm is a mix of threaded and multi-process setups so rather than one process per request you only need a couple processes, each of which has several threads for processing requests. I've been going this route as it seems to provide about as good of performance as nginx + php-fpm while still maintaining .htaccess compatibility.
-
The other two records must have some difference in the value for CondSURNAME. Perhaps extra spaces around the word, or other invisible characters. Perhaps they are a different case and you're using a case-sensitive collation. Run this query to check the values: SELECT HEX(CondSURNAME) FROM tblConductor If all three rows are truly identical that will return three identical rows. If there is a difference in spacing, you will see different values.
-
The quotes are cause errors in your query because you are not escaping your variables, or to be more precise, you are escaping them but then you over-write them with the original un-escaped values: //You escape them here like you should $notes = mssql_escape($_POST['notes']); $notes2 = mssql_escape($_POST['notes2']); $notes3 = mssql_escape($_POST['notes3']); //But then you replace them with the unescaped values. $notes = $_POST['notes']; $notes2 = $_POST['notes2']; $notes3 = $_POST['notes3']; Remove those last three lines.