-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
can someone give me tips on how to make my site look less bland
Adam replied to turkman's topic in Website Critique
I think the first thing you need to concentrate on is developing a system that doesn't pop-up a message like that on the first visit. -
There's a number of ways of doing this. If a database is a little overkill, you may be best going with an array: $source_phone_numbers = array( 'CPC' => 'xxx', 'Organic' => 'xxx', ); if (isset($_COOKIE['UTM_Source_Cookie'])) { $source = $_COOKIE['UTM_Source_Cookie']; if (array_key_exists($source, $source_phone_numbers)) { $phone_number = $source_phone_numbers[$source]; } } if (!isset($phone_number)) { $phone_number = 'default number'; } echo $phone_number; This method's a lot better than a series of if..else conditions (even a switch in my opinion) as it allows room for growth with minimal configuration. Edit Actually reading back your post, this may be over kill as well. Depends how many different sources you're going to have I guess. Best suggestion would be a switch: $source = isset($_COOKIE['UTM_Source_Cookie']) ? $_COOKIE['UTM_Source_Cookie'] : ''; switch ($source) { case 'CPC': $phone_number = 'xxx'; break; case 'Organic': $phone_number = 'xxx'; break; default: $phone_number = 'xxx'; }
-
so i'm still going to have to define these 10 vars in each of these 10 functions anyway, which is what i was trying to avoid... No you don't. Once you've declared the variables globally you can define them within one function, and then access them (or define them again) within another. Probably better explained with a simple example: var foo; // notice the "var" statement function test1() { foo = 'bar'; // notice no "var" statement } function test2() { alert(foo); } window.onload = function() { test1(); test2(); }
-
It doesn't matter what differs where, within the function the variables are out of scope (the function is unable to see them). First modify the function to accept 2 parameters: function bumpup($now, $addate){ Then call the function, passing the 2 variables: $now=date("Y-m-d H:i:s"); $addate='2010-01-27 13:59:13'; bumpup($now, $addate); // pass the values here echo '<br> ----------------------------- <br>'; $now=date("Y-m-d H:i:s"); $addate='2010-07-27 13:59:13'; bumpup($now, $addate); // pass the values here
-
It's nothing to do with the server. When you send output to the browser (even white-space) the response headers (your redirects, cookies, etc.) are sent first. This means once output has been sent, you're unable to set anymore response headers. I don't know if this is just from copying the code into the post, but I can see an empty line above your PHP tag. quite possibly this is the cause of your problem.
-
Try something like: // perform query // assuming $data contains the row $valid = false; foreach ($data as $chkbox) { if ($chkbox == true) { $valid = true; break; } } if ($valid) { // do something here }
-
Variable scope. Once inside the bumpup() function, $now and $addate do not exist. You need to pass them as parameters.
-
Whether it's a local variable or global variable.. on the next request it won't exist anymore. Without using a database to track user IPs, really your best bet is to set a session variable and/or cookie.
-
They're known as "CAPTCHA" (Completely Automated Public Turing test to tell Computers and Humans Apart) images, and no that's not how they're done. The basic approach is to generate a sequence of numbers and/or letters, present them in a way that isn't easily readable by a computer (i.e. an image - which you can use the GD library to generate), and store the sequence within a session variable. Once the user enters the CAPTCHA sequence their entry is validated against the value in the session variable. If it's correct the form is processed, but if it's false a new CAPTCHA sequence is generated and they have to try again.
-
IE strikes again... JQuery, runs as expected in FF, Opera, Chrome.
Adam replied to Andy-H's topic in Javascript Help
Do you have an online demo? -
JavaScript is an event driven language. You need to declare the variable globally, but define it within a function (triggered by an event): var n1; var n2; // ... Then in the function: n1 = document.getElementById('net1').value; n2 = document.getElementById('net2').value; // ... Note "var" is used globally, but not within the function.
-
Which DB library/class are you using?
-
Generally provided there's been a MySQL connection, PHP will know to use that link identifier if none is specified. Actually how he has has it is perfectly valid. Only using single quotes or referencing an array index would cause problems.
-
Hmm, not going to trawl through all that.. but nothing stands as to why it would produce that error. Something I've noticed in the Apache error log though: "Portal.php&failed_log"? What's the form action?
-
Okay then, so what does checkform() do?
-
Ha.. I don't think anyone will ever forget Rivaldo's dive either!
-
Can you show the submit button code?
-
You can generate the root path with: $root_path = dirname(__FILE__);
-
You mean football Try rugby. Although Germany did have ~2 good games, the only the tactic they really had was getting goals on the counter-attack; they're awful at set pieces. Germany didn't deserve to win it to be fair.
-
Second that! Bommel especially has been annoying me in almost every match Holland played. He's far too aggressive and clumsy, yet managed to escape getting sent off even once! He's got that ass-hole look about him though!
-
As said, looks basic. Aside the logo, there's no real design thought put into it at all; really just tables with some borders.
-
You mean convert the PDF to HTML?
-
Case is returning an Echo before the entire procedure is complete
Adam replied to myrddinwylt's topic in PHP Coding Help
Wow, I don't think you realise how not-smart you just sounded with that allegation. I'm not going to go into what's wrong with GOTO statements, or try to understand how a GOTO statement would solve your problem?? But just to add insult to injury, check out the PHP GOTO statement, available as of PHP5.3. To answer your original question; during long and/or memory intense loads like in your situation, PHP attempts to periodically output whatever is in the buffer. This is normally a positive thing in most situations as it free's up memory and resources. If you want to stop that you need to take control of the output buffer yourself.