ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
Keep it as base 64, don't decode it. You're telling the browser "this image tag is base64 encoded data" and sending it DECODED data.
-
How Can I Get The Text Of Textarea In Html Using $_Post?
ManiacDan replied to dev-ria's topic in PHP Coding Help
or the <pre> tag. -
Don't use extract at all, just use the array. If you use extract, you're creating mystery variables and duplicating content.
-
php > $s = strtotime('2012-01-01'); php > $e = strtotime('2013-01-01'); php > echo date('Y-m-d', ($s + $e)/2); 2012-07-02 Note that your math is wrong. 7/2 is halfway through the year, not 7/1. Months are not all the same length. Also, this probably won't work right on 32-bit systems.
-
List Cities And How Many Records Match That City.
ManiacDan replied to derekshull's topic in PHP Coding Help
Use curly braces instead of while: and endwhile: while ( $something ) { //loop contents } -
List Cities And How Many Records Match That City.
ManiacDan replied to derekshull's topic in PHP Coding Help
Do this by hand. Find a city and state combo with more than one row in need where status is 'posted'. Is there such a thing? -
List Cities And How Many Records Match That City.
ManiacDan replied to derekshull's topic in PHP Coding Help
SELECT city, count(city) as num FROM needs GROUP BY city ORDER BY count(city) DESC -
Now you're just...not making any sense. What I've learned so far: 1) The code you post is not your code, there is other code that we're not seeing. This right here means you can't be helped. 2) "Not working" means that in certain browsers a javascript function ("upload") isn't being called. 3) You can print a DIV but not a script tag in the line right after it? Or maybe you mean everything is printing just fine and this is a javascript problem? Or...maybe? What's the current state? Both of these print statements are working as designed and specific browsers aren't executing the function? The print statements only work when there's two of them, regardless of browser? What's happening?
-
You need a die after your header regardless, and remove your ?> tag, if there's whitespace after it it could screw up other header code. You've verified that this specific post value exists in all browsers?
-
How To Implement The Dtsearch Engine In Php
ManiacDan replied to santhamtnj's topic in PHP Coding Help
dtSearch appears to be a desktop file searching and data mining application. It's available for desktop programming languages like .Net and Java, but not for non-desktop languages like PHP. What problem are you trying to solve? -
Assigning Specific Array Keys To Seperate Variables
ManiacDan replied to dinita's topic in PHP Coding Help
That was a general tip about correct code, your code is still not written right because you're selecting 1 column and expecting 4. You want something like: $sql = mysql_query("select answer FROM answers WHERE question_ID= 1 "); $answers = array(); while($row =mysql_fetch_row($sql)) { $answers[] = $row[0]; } echo "The answers are: " . implode(', ', $answers); -Dan -
Assigning Specific Array Keys To Seperate Variables
ManiacDan replied to dinita's topic in PHP Coding Help
1) You were using ['0'] which is a string. [0] is a number. 2) Don't ever use sequentially numbered variables. You want to use arrays -
Clickable where?
-
Assigning Specific Array Keys To Seperate Variables
ManiacDan replied to dinita's topic in PHP Coding Help
Your code doesn't match the errors. Please show the actual code you're using. -
Also not reading all this, but if there's a valid answer to Requinix's question: what need does this fulfill or what problem does this solve that __call() does not?
-
Interesting Behavior In Php's Handling Of $This
ManiacDan replied to ManiacDan's topic in PHP Coding Help
I didn't really want to say this because I don't like giving people bad ideas, but this is a way to fake multiple inheritance or a sort of fake-y interface that doesn't require additional coding on the interfaced objects. It's still definitely weird and you shouldn't ever do it, but it's interesting, especially since it respects the invalid context and doesn't allow private/protected access. It knows that $this is another object, but uses it anyway. Such an odd choice. -
Grandma's Boy is about a game tester, not a coder.
-
It was here. I fixed it for the new poorly spaced forum.
-
I first noticed it when I tried to post a "picture" of my dog.
-
The inconsistent spacing in [ code ] tags is starting to make me twitch.
-
Barand was proving that even if you used LIKE properly, it would still return both terms with "chester" in them, not just "chester city"
-
Programming is boring and slow. There aren't any movies about accounting either. The only thing you're going to get is movies like The Social Network or (to a significantly lesser extent) Swordfish. Few movies portray programming accurately. The Matrix trilogy portrays modern operating systems and software correctly, even going so far as to show an actual bash exploit in the third one. I can personally attest that the commands typed at the beginning of Firewall are indeed the proper way to null route an incoming IP. Later on in that movie he shoved the bare wires from a broken scanner into an iPod Mini and slapped the scanner light against a terminal, magically transforming the makeshift device into a portable OCR scanner. Computers are boring and difficult. Movies are exciting and easy. Hacking the President's Internet is the best you're going to get.
-
Ah, didn't see your table name had changed. Mikosiko is right.
-
Consider the following code: <?php error_reporting( E_ALL | E_STRICT ); class staticClass { function staticMethod() { //when called statically from the global scope, this throws a fatal error due to $this echo $this->echoMe . "\n"; } } class dynamicClass { public $echoMe; public function __construct( $echoMe ) { $this->echoMe = $echoMe; } public function thisShouldNotWork() { //calling the staticClass method statically does NOT throw a fatal error as expected, the $this reference inside //staticClass is assumed to be a reference to the current instance of dynamicClass instead staticClass::staticMethod(); } } $a = new dynamicClass( "Hello, World!" ); $a->thisShouldNotWork(); /* The above throws a strict warning BUT STILL PRINTS "Hello, World!" Strict Standards: Non-static method staticClass::staticMethod() should not be called statically, assuming $this from incompatible context in test.php on line 22 Hello, World! */ The aptly named function thisShouldNotWork calls a method statically when that method was not defined as static. Even though the function is called statically, $this exists inside that function and can be manipulated and accessed. However, $this inside of staticClass points to a different class. No inheritance is given by the code, but one class is able to access another's variables using $this. PHP "falls back" to the last valid instance of $this since it's a super-global. Only a strict warning level will tell you that something wacky is going on.
-
How To Save Image From Web (Remote Image) Using Fsockopen()
ManiacDan replied to shilpa505's topic in PHP Coding Help
They could be dumb!