-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
Access denied for user 'estatec'@'localhost' (using password: NO)
salathe replied to estatec's topic in MySQL Help
Change <? to <?php in your datosconeccion.php file. -
Bingo. And because it's a URL, it's also a URI. No, a URI is either a URL, a URN or both. This is none of them.
-
URL is a sub-type of URI, so if something is a URL then it is also a URI. The other way around isn't always true: a URI is not always a URL. The example (www.phpfreaks.com) that you gave is not a URL since there is no scheme part (http). That example allows one to identify a resource (remember what URI stands for) but not a means of locating the resource (e.g. using the http protocol; remember what the L in URL means).
-
I was hoping that you would rethink the logic being used here, but maybe that was too much to ask. Think about what your regular expressions are doing. 1. Replace any single non-alphanumeric character with a space. 2. Replace any occurrence of one or more consecutive whitespace characters with a dash. There is never any chance of an alphanumeric character also being a whitespace character, it's just not possible. Anything non-alphanumeric will become a space, then any group of spaces will become one dash. The above two steps can be replaced with a single one doing the same job: 1. Replace one or more consecutive non-alphanumeric characters with a dash. strtolower(preg_replace('/[^0-9a-zA-Z]+/', '-', $a['item']));
-
Storing a DateTime object in $_SESSION yields an error
salathe replied to jhsachs's topic in PHP Coding Help
Serialization of DateTime objects was only added to the language in PHP 5.3.0. Just to show you that's the case, the following script was executed on many different versions. <?php $dt = new DateTime('2011-09-01', new DateTimeZone('UTC')); $serialized = serialize($dt); $unserialized = unserialize($serialized); echo $unserialized->format('r'); ?> The results were: -- 5.2.0 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.1 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.2 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.3 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.4 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.5 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.6 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.8 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.9 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.10 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.11 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.12 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.13 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.14 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.2.15 -- Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in /tmp/fwY5gl on line 6 -- 5.3.0 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.1 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.2 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.3 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.4 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.5 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.3.6 -- Thu, 01 Sep 2011 00:00:00 +0000 -- 5.4.0 -- Thu, 01 Sep 2011 00:00:00 +0000 -- trunk -- Thu, 01 Sep 2011 00:00:00 +0000 -
Not in public, m'dear. P.S. skwap, you need to swap the $mid and $url positions in the preg_match() call. Just to be sure you know what the problem is.
-
Why do you want to combine two completely unrelated regular expressions, with two completely unrelated replacement values, into one?
-
Easy. You say, "Because I have concerns informing my current employer/line managers that I am applying for other jobs, because they will go ballistic." It's just not something you'd write in a CV.
-
Don't add that to your CV.
-
Just in case it wasn't clear from the replies above, skwap, you have your arguments switched. $url and $mid should be the other way around. P.S. See, I can echo too!
-
If the commit has only ever existed locally, then you're in luck. If the commit was pushed anywhere (anywhere!) then, depending on where the commit may have spread to, life could be painful. So, before offering solutions, exactly where is the commit now? Just in your local git repo, pushed to a super-tightly-controlled remote, only wherever your colleagues (if there are any) might have it, or potentially anywhere?
-
You must be. Wingrep happily searches for literal dollar characters with \$
-
Is there a question?
-
Happy to help in guiding you in the right direction. What?
-
Don't use regex. PHP has built-in XML parsing tools available to make the job much easier. One such tool is SimpleXML and the example below shows how to loop over each <item> and display the associated image. Have a read through the SimpleXML Examples page too. $feed = simplexml_load_file('http://feeds.nationalgeographic.com/ng/photography/photo-of-the-day.atom'); foreach ($feed->channel->item as $item) { printf('<img src="%s"><br>', $item->enclosure['url']); } (And here's it working online.)
-
Your line of code is incorrect given the XML shown. $xml will be the <parent> element so to try and access the <street> you would want: $street = $xml->children('cmn', true)->address->street; If the <cmn:address> is not present, the above will assign NULL to $street with no warnings or errors.
-
Will any code given in this thread find its way into your "best scripts and software" site?
-
People who abuse their power are kept in their existing roles, or promoted.
-
Is there any reason why you want to use regex over, say, a real HTML parser? A basic example would look a bit like: $doc = new DOMDocument; $doc->loadHTML($a); $h1 = $doc->getElementsByTagName('marquee')->item(0); echo $doc->saveXML($h1);
-
I'm going to guess that "locally" you're using PHP 5.3 and "not locally" you're using PHP 5.2 (or lower). The former allows you to use a variable as you have, the latter does not. In short, prior to PHP 5.3.0 you must hard code the class name there.
-
Is there any equivalent function of dump_mem in php5 ?
salathe replied to colap's topic in PHP Coding Help
The "equivalent function" will vary depending on which XML-related classes/functions you want to use in place of the PHP 4 DOMXML. You will have to change far more than that one line of code. Options include: DOM SimpleXML XMLWriter -
Yes, the relative path will work. Remember that relative paths aren't necessarily relative to the file that the code is in, but instead the "current working directory".
-
You can't use a web address with glob like that. Specify the folder path on the filesystem instead (e.g. C:\blah\something\images\gay).
-
Need help with function date() and strtotime()
salathe replied to JuanKiller69's topic in PHP Coding Help
If you're using PHP 5.3, then use DateTime::createFromFormat() (if you're not, why not?!). $date = '15/05/2011'; $datetime = DateTime::createFromFormat('d/m/Y', $date); $mysql_date = $datetime->format('Y-m-d'); If you want to stick with strtotime() then formats that it will accept are detailed under Date Formats.