-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
What happens if you run the script manually?
-
"Stopped" meaning what? Cronjob not running? Script not generating backups? Not emailing them to you? Emailing an empty file?
-
Need help accessing an attribute from parent class
requinix replied to eldan88's topic in PHP Coding Help
If you have PHP 5.3 you can foreach(static::$db_fields as $field) {Then make $db_fields static. -
Then now's the time to start on it. To get the file extension, pathinfo is one method you can use. substr is another (pay close attention to the explanation of the $start parameter). Try some examples to see how they work.
-
Before you try to do the arithmetic yourself, see if there are other solutions. What happens if you do a mysql_query("SET time_zone = 'Europe/London'");beforehand?
-
You might be on a system that doesn't support dates that far in the past. You're doing the SQL queries yourself? Do the date formatting in the query.
-
Use a background-image or a (which supports more than just strings for button labels). Also, Invalid "type".
-
fputcsv is your friend.
-
Are there headings? They'd be the first row in that CSV. You should actually see them already.
-
The "computer repair" ones are all using that computerRepair.php script. That's probably why they all have the same title: the script doesn't try to change it or anything. But without seeing the code we can't do anything but guess.
-
There's one key step you missed. Take a look at the example and make sure you did everything it talks about.
-
while($max Probably don't want a maximum of 12 months, right?
-
Count your columns and count your values. If you have mysqli then you really should be using prepared statements for your INSERT. You're open to SQL injection right now.
-
You can modify connect_db() so it always returns the same object each time it's called. function connect_db() { static $connection = null; if (!$connection) { $connection = new PDO(/* ... */); // and whatever else } return $connection; }That bit with static $connection (so PHP "remembers" $connection across calls) makes this a singleton. Simply reusing $connection might be enough, but if that variable ever drops out of scope (ie, you use it inside a function or class method) then it'll get cleaned up. On the down side this doesn't make it easy to close the connection, should you want to do that manually at some point. Like if you have a long-running script that only needs the database a little bit early on. If that case arises then you should switch to a full class implementation instead of the simple function above.
-
If you already got the data earlier then why do you need another query? Can't you run just this query once, get the first row, output it the special way, and output the rest normally?
-
It's a good albeit generally unnecessary practice to close it when you're completely done. Not after every query. 1. What's mysql_prep() doing? I'm not too confident you need it. 2. That's basically what your code should look like. Is connect_db() returning a new PDO object every time? That's the inefficient part. Create a PDO object the first time and reuse that every subsequent time; the Singleton pattern is typically how that happens. 3. I did find this that explicitly says the connection is closed once the object goes away (eg, with $connection=null).
-
You "close" the connection after each query? No no. Leave it open and let PHP close it for you. It's quite possible that PDO has coding where garbage collection frees the underlying connection while mysql's coding doesn't (especially considering how it's not object-oriented).
-
How can I write CSS with PHP? - I tried and i have lost styles
requinix replied to jarv's topic in PHP Coding Help
header('Content-type=text/css');should be header('Content-type: text/css'); -
Because $m is also an array. This isn't rocket science.
-
It's an array. You need some sort of loop, like a foreach.
-
Warning: mysql_num_rows() expects parameter 1 to be resource
requinix replied to ZeTutorials101's topic in PHP Coding Help
The query failed. Run it manually and see what errors you get. -
...Or if you want it to run in the background. Which is what that does.
-
I believe what you have now translates as (empty query string && website.co.uk) || (www.website.co.uk)so try RewriteCond %{HTTP_HOST} ^website\.co\.uk$ [OR] RewriteCond %{HTTP_HOST} ^www\.website\.co\.uk$ RewriteCond %{QUERY_STRING} ^$
-
Not really. What kind of code are you noticing is slow? How are you constructing the PDO object and are you using any settings?
-
And how exactly do functions and methods "have resources"?