
ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
Send XML on to the client side as a .xml file
ignace replied to souravhainpagal's topic in PHP Coding Help
i want that xml to be sent to the client side and then another page will use that XML to display the data... Back to my original answer: Or use XSLT. If this is not what you want then you are gonna have to clarify yourself properly. -
Send XML on to the client side as a .xml file
ignace replied to souravhainpagal's topic in PHP Coding Help
Oops misunderstood your question. Why don't you just let the user upload the file? Otherwise you'll have to reference it through file:/// but then it'll have to be at an exact location and the client must allow it. -
Send XML on to the client side as a .xml file
ignace replied to souravhainpagal's topic in PHP Coding Help
Ajax: Using jQuery: $.get("path/to/xmlfile.xml", function(xml) { console.dir(xml); }, 'xml'); -
I use phpDoc for a very long time now. Never heard of Natural Docs before but it looks really good.
-
Here's an article describing divers methods to hide the referrer. http://lincolnloop.com/blog/2012/jun/27/referrer-blocking-hard/
-
Only cake for badged members
-
http://php.net/mysql-real-escape-string Look at the big red box
-
That's how it should be done: if (get_magic_quotes_gpc()) { $_POST['subjects'] = stripslashes($_POST['subjects']); $_POST['codeA'] = stripslashes($_POST['codeA']); } $update = sprintf("INSERT INTO newdb (subject, code) VALUES ('%s', '%s')", mysql_real_escape_string($_POST['subjects']), mysql_real_escape_string($_POST['codeA'])); $result = mysql_query($update);
-
mysql_real_escape_string will add slashes for any character's (' and ") which could break your SQL. That said relying on mysql_* functions should be avoided and you should use the mysqli_* functions instead or PDO. http://php.net/mysqli-real-escape-string
-
No. You only load what you need. Your factory will build the proper objects in the form of a Proxy or a Ghost object if need be. So that if for example you need the profile information, but you did not load it the first time (a Profile object with only an ID aka Ghost object) it will hit the database and load the profile information. http://en.wikipedia.org/wiki/Lazy_loading#Ghost
-
Or if you just want it copy another: $('#menu1, #menu2').change(function(e) { var $this = $(this), other = $($this.attr('id') === 'menu2' ? '#menu1' : '#menu2'); other.val($this.val()); }); http://jsfiddle.net/DdCpX/
-
Your real question is: how do I cleanly separate an SQL query from the code that creates the objects. There are a few ways you can do this, here is one: class UserRepository { private $dbAdapter; private $factory; private $identityMap; public function findProfileById($id) { if ($this->identityMap->has($id)) { return $this->identityMap->get($id); } $sql = $this->dbAdapter->select('..')->from('..')->join('..', '..')->where()->equals('id', $id); $row = $this->dbAdapter->query($sql); $inst = $this->factory->newInstanceFromDbResult($row); $this->identityMap->add($id, $inst); return $inst; } } class UserFactory { public function newInstanceFromDbResult(DbResult $foo) { // creation code return $instance; } } The factory creates the aggregate root and any relating objects like UserAccount, Profile, and UserContactDetail. The Repository is an in-memory collection of aggregate roots. It hits the database whenever you try to load a root it does not contain. Even if you would opt to go with Doctrine, you would still at some point have to write the query and do all the necessary joins because if you don't and trying to access a not-yet-loaded field will hit the database to load ALL the necessary data.
-
If your class is named like this: namespace Foo\Bar; class Bat {} And it is located in app/library/Foo/Bar/Bat.php. Then your include path should be: set_include_path( realpath('app/library') ); So that when PHP looks for Foo\Bar\Bat it will find it in app/library/Foo/Bar/Bat.php. Change your directory structure or alter the include path so that it matches with where your classes live.
-
Seems like you are catching up!
-
Wherever you wrote: [exec]echo include('2.php');[/exec] Change it to: [exec]include('2.php');[/exec]
-
[exec]include('2.php');[/exec] the 1 is because include returns true, echo true; prints 1 on screen.
-
Something like this? // so if the value THISVALUE is the only capitalised value then the if statement should return false // .. but fail if all are lower case (or if THIS VALUE is the only capitalised value). $test = false; if (preg_match_all('!([A-Z]+)!', $string, $matches)) { if (count(array_keys($matches[1], 'THISVALUE', true)) === 1 && count($matches[1]) > 1) { $test = true; // So, if THIS VALUE exists as well as other capitals, then it should return true } } if ($test) { // THISVALUE existed more than once }
-
https://github.com/kriswallsmith/Buzz Your directory structure should look something like: vendor `- Buzz `- Geocoder autoloader.php In your autoloader then should be: set_include_path( implode(PATH_SEPARATOR, array('.', realpath('vendor')) );
-
That is due to php being unable to locate the class. Make sure you have something like this in your bootstrap file: set_include_path( implode(PATH_SEPARATOR, array('.', realpath('path/to/library')) ); spl_autoload_register(function($className) { $className = ltrim($className, '\\'); $fileName = ''; if ($lastNsPos = strripos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; require $fileName; });
-
You can develop your website locally, but those changes will not be visible to online users until you FTP them to your server. http://www.apachefriends.org/en/xampp.html If you are looking to make parts of your website offline available, you can use this: http://www.catswhocode.com/blog/how-to-create-offline-html5-web-apps-in-5-easy-steps
-
The code I provided was an example and untested. It's not advised to just copy-paste it, since I have no idea in what context it is being used.
-
$r = bcmod(bcpow(254, 187), 319); // 100 Edit: damn 30 seconds late Edit: Actually echo bcmod(bcpow(254,187),319) = 100; Returns an error