scootstah
Staff Alumni-
Posts
3,858 -
Joined
-
Last visited
-
Days Won
29
Everything posted by scootstah
-
You're over complicating this a bit. All you need is one preg_replace. $text="Click [link]http://www.google.com.eg[/link] or click [link]http://www.yahoo.com[/link] or click [link]http://www.hotmail.com[/link]"; $search = '/\[link\](.*?)\[\/link\]/si'; $replace = '<a href="$1">$1</a>'; $text = preg_replace($search, $replace, $text);
-
That depends on a lot of factors... but, yeah, in theory you're correct.
-
There's a bunch of options in PHP for eCommerce software. Some are more customizable than others, so search around and find one you like. Some suggestions are: Magenta, Wordpress with WP e-Commerce, Drupal with Ubercart, or Joomla with VirtueMart. Also, make sure that you do not store credit card information on your own servers. There are pretty stiff regulations in place for doing so, and if you have to ask, you are not experienced enough to do it. It's better to use a trusted third party service for that kind of thing.
-
If this is a Flash game, I don't think it's doable with PHP. You would most likely have to manipulate the client for that, which PHP can't do. There are a number of ways to inspect POST data. I like the TamperData addon for Firefox, but you can use a number of other tools like Firebug or Live HTTP Headers (both are addons for Firefox).
-
In my opinion, you should host the server near your largest target audience. I don't think it would matter for SEO. The only thing that I can think of that would make a difference is the TLD. I'm sure region is factored into some results.
-
SELECT a.myfield FROM mytable I'm not super familiar with Oracle, but this doesn't look right. I would think that since there's no alias defined, that query should error. Also, if there is no rows returned, I'm kind of surprised that while (($row = oci_fetch_array($stmt, OCI_BOTH))) { isn't throwing an error too.
-
strtotime EDIT: Or mktime
-
I've seen FALSE used for that. Or, sometimes you can just give it a default. I believe you can also give it an empty string.
-
Loop through and enter <br /> when new day
scootstah replied to defroster's topic in PHP Coding Help
Not tested, but try something like: while($row = mysql_fetch_assoc($result)) { $current = date('d', strtotime($row['date'])); if (isset($previous) && $previous != $current) { echo '<br />'; } $previos = $current; } -
No, people could still type in the file names and access them. Add this to your .htaccess: Order Deny,Allow Deny from All EDIT: This has to go inside the directory you want to disallow.
-
Again, are the database credentials (mainly $serv and $data) correct and what you expect?
-
In that case, there's no issue with the query. It just looks like no rows are being returned. To test that theory: Place echo count($sth->fetchAll()) . ' rows'; after $sth->execute(); What do you get?
-
Try this instead: echo '<pre>' . print_r($sth->errorInfo(),true) . '</pre>';
-
Put echo '<pre>' . print_r($dbh->errorInfo(),true) . '</pre>'; after $sth->execute(). What do you get?
-
I don't see any syntax errors. Are you sure the database credentials are correct? Do you have error reporting turned on? At the top of your script: error_reporting(-1); ini_set('display_errors', 1);
-
Yes. For PHP files, you can either restrict access with a .htaccess file, or put the files outside of the docroot. BUT, neither of those will work for Flash files, because the browser has to be able to access them. You can't (to my knowledge) fetch a Flash file with PHP in a way that makes it not possible to download.
-
Flash has to be viewable by the client/browser, and so you can't put it in a non-publicly facing directory. Since the browser can see the file, it is very easy to download with one of the many Firefox plugins, or by just finding the resource header. However, I believe you can hide downloads from clients using HTML5 WebSockets, but I'm not positive. I do know that GrooveShark.com switched to an HTML5 player a while ago, and you can no longer download songs with the methods I was talking about above - but you used to be able to, when they had a Flash player. On the other hand, if you don't plan on streaming the Flash files, then you can hide them from the public, and just use a forced download header to download them when requested.
-
PHP switch, case, and passing info from one page to another
scootstah replied to rawkhopper's topic in PHP Coding Help
You could put the whole script on pastebin, or upload it as an attachment. -
Yeah, but too bad all the awesome new features won't really be mainstream for at least another year. I mean, 5.3 is barely mainstream at this point. Most hosts support it, but it's not always enabled by default.
-
If you're using Flash, unfortunately anyone can download the stream very easily, as long as they can view it. To prevent directory indexing in Apache, add this to a .htaccess file: Options -Indexes. This directive will work for any subdirectories as well, from just the one file.
-
PHP switch, case, and passing info from one page to another
scootstah replied to rawkhopper's topic in PHP Coding Help
If your switch is just including pages then it shouldn't be a problem, since the included page can access the $_GET global. -
In the future, please place code inside tags. The form action is the page which the form will send its data to when someone submits it. Usually, this is the page which will process the form. It is possible that the theme already has functionality in place for that. You would most likely put your email on the page that processes the form, so that it can be emailed out. Again, the theme might already handle this.
-
Best practice: self::method() or $this->method()
scootstah replied to silkfire's topic in PHP Coding Help
It's also worth noting that when in a static context, static:: can sometimes be superior to self:: It implements late-static-binding. In a nut shell, that means that static:: works on the same idea as $this, in that it refers to the class in which it was called and not in which it resides (for lack of better terminology). So, in my earlier example if you changed self::getModel() to static::getModel(), you would end up with "Ford F150", just like with $this->getModel(). In addition to that, it makes unit testing a lot easier for static methods. -
Best practice: self::method() or $this->method()
scootstah replied to silkfire's topic in PHP Coding Help
It is a common misconception that self:: is only for static methods, and $this is only for non-static methods. This isn't entirely true, though, and both can be used in both ways. self:: refers to the current class, and $this refers to the current object. Consider this example: <?php class Car { public function getMake() { return 'Ford'; } public function getModel() { return 'Focus'; } public function getVehicle() { return $this->getMake() . ' ' . $this->getModel(); } } class Truck extends Car { public function getModel() { return 'F150'; } } If we create a new Truck object, and call the "getVehicle" method, it will output "Ford F150". <?php $truck = new Truck; echo $truck->getVehicle(); // Ford F150 It does so because $this refers to the current object, which is Truck. If we change $this->getModel() to self::getModel(), it will use the current class's (current being the class that self:: resides in, in this case Car) getModel method. <?php ... public function getVehicle() { return $this->getMake() . ' ' . self::getModel(); } ... $truck = new Truck; echo $truck->getVehicle(); // Ford Focus I hope that severely lackluster example helps you understand. -
Oops, I thought empty() choked too. Yeah, as long as you're not logging Notice's either. The log would probably be massive. I too code with all error reporting on, and I think every developer should. Leaving undefined variables or array indexes floating around is just sloppy in my opinion.