PHP

I have an array with tree data (by parent id). I want to convert it to multidimensional array. What is the best way to achieve that? Is there any short function for that? Source array: $source = array( '0' => array( 'Menu' => array( 'id' => 45 'name' => 'Home' 'parent_id' => 1 ) ) '1' => array( 'Menu' => array( 'id' => 47
i keep receiving this error each time i try to submit the a form deletion form. Warning: Cannot modify header information - headers already sent by (output started at C:xampphtdocsspeedycmsdeleteclient.php:47) in C:xampphtdocsspeedycmsdeleteclient.php on line 106 is there something wrong with my code? what do i need to change to make it work? <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // ***
I am currently using below function to sanitize my $_POST and $_GET against SQL injection. Unfortunately, I cannot post code through it, for example: "<a href test". How does Twitter do it? function _secinput($variable) {return filter_var(mysql_real_escape_string($variable), FILTER_SANITIZE_STRING); } Plus, can anyone tell suggest me if I can improve it in any ways? There can never and will never be one function to sanitize everything. You must choose the right tool
I need to save an image from a php URL to my PC. Let's say I have a page http://example.com/image.php holding a single "flower" image, nothing else. How can I save this image from URL with a new name (using PHP)? Please help. If you have allow_url_fopen set to true: $url = 'http://example.com/image.php'; $img = '/my/folder/flower.gif'; file_put_contents($img, file_get_contents($url)); Else use cURL: $ch = curl_init('http://example.com/image.php'); $fp =
How do you organize and manage your helper objects like the database engine, user notification, error handling and so on in a PHP based, object oriented project? Say I have a large PHP CMS. The CMS is organized in various classes. A few examples: the database object user management an API to create/modify/delete items a messaging object to display messages to the end user a context handler that takes you to the right page a navigation bar class that shows buttons a logging
OK, so now I've got two problems. I've got a list of filenames. Some of those filenames may contain a HTML hex color reference. Like #11AACC. Also I'm interested only in image files (extensions jpg, jpeg, png, gif and bmp). So I'd like a regexp that would match if the file extension is one of the above, plus, if there is a HTML color reference anywhere in the string, it would get captured too. If there are multiple references, I don't care which one gets captured (there should be only
If i'm using the findBy method of the respository class, how can I limit the size of the result set? In Doctrine 2.1 method EntityRepository#findBy() now accepts additional parameters for ordering, limit and offset. see full list new features in doctrine 2.1 The findBy() method of the generic repository class doesn't support this. I would write your own repository (as outlined here) and override findBy() to take additional parameters. Your new implementation could use the
I have a simple php function that is being called when a form is submitted: function uc_paypal_ec_submit_form($form, &$form_state) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Submit order'), ); return $form; } What I need is to be able to do a simple Google Analytics call like this: _gaq.push(['_trackPageview', 'virtual/formSubmit']); I've tryied a few options but nothing
I have the following array, it's full of gibberish (I got bored using lorem ipsum so I started typing random stuff -- I'm testing ¬_¬). I used mysqli_fetch_array to fetch this array. [array1] Array ( [0] => Array ( [title] => this is a new thread, and it is great and it should work [thread_id] => 27 [content] => <p>hello, how are you? and what are you doing y'all and this should work</p>
How to send a file to the browser as attachment if the meant file resides on a 3rd party server (without prior downloading or streaming)? From another server without downloading to your server: header('Location: http://thirdparty.com/file.ext'); Without downloading the file locally you have no authorization in the external server, so you have to tell the browser what to do, thus the redirect header, it will tell the server to go directly to the url provided, thus loading the
I want to give a client the ability to manually download a backup of his database. I am coding the site using PHP and MySQL. So after the admin user has logged in there would be a link in the menu to download a .sql file to the local computer. How can I accomplish this with PHP? This can get messy trying to back up a database from PHP, you would be better of letting MySql handle this, and the best way to tell mysql to do this is with a shell script: #!/bin/bash # Shell script to
Possible Duplicate: Advantages Of MySQLi over MySQL I am building a large database and wondered which is the best to use? I am sanitizing my values now and escaping characters for security but I would like to know the different benefits of these mysql querys in php? Thanks. Use MySQLi over the older MySQL functions. The "i" stands for "improved". The list of improvements can be found in the docs. Why not use PDO instead? You have the benefit of prepared statements