php

How to get started with sql and php?

I am just getting started in php and sql, I was wonder if how to link sql database to on my php code, I know how to create databases and i know a little about php, but i don't know how to link the databases to my code. i am using a database on my local server that i set up and i have already created a database, i tried writing a php scri...

How to indent text in a select drop down option menu using PHP & CSS? [REDUX]

I asked a similar question earlier but I'll ask it again in a different way because I re-worked the code a little. I was wondering how can I indent categories and endless sub categories that I have in a select drop down menu using PHP & CSS? Here is my PHP code to display the select drop down. echo '<select name="parent_id"> <o...

php book recommendation

Possible Duplicate: What is the best PHP programming book? I am a seasoned developer using microsoft technologies. Licensing and hosting prices are pushing me towards opensource. I want to develop a website using php apache and my sql, please recommend me a book for learning web development using php apache and my sql. i wil...

Errors persisting Doctrine 2 entity once user is logged in with Zend_Auth

i am having problems persisting a Doctrine 2 entity (Post) when the User is logged in with Zend_Auth. i am quite sure its the login as the code runs, when the user is logged out, and fails once the user is logged in. and it seems that the identity returned from the Zend_Auth::authenticate() plays a role in affecting the error message. ...

Save textarea to MySQL and preserve line breaks

Imagine a blog or cms system (PHP and MySQL). I want to let the user enter some text in a textarea and save it to the database. The type of the field in the database is TEXT. I want to preserve line breaks and print them later. I know I can do this with PHP's nl2br-function, but how do I protect this string against SQL-injection attack...

PHP merge similar values in an array

Hi, say I have 1 array: $arr = (a => array(1,2,3), b => array(1,2,3), c => array(4,5), d=> array(8,9,10), e => array(8,9), f => array(9,10); I would like to merge similar values, so that I would get: Problem #1 (similar values, harder): $new_arr = (a_b => array(1,2,3), c => (4,5), d_e_f => array(8,9,10)); Problem #2 (exactly same...

Benefits/Examples of using a Service Layer in MVC patterns

Hi, We're contemplating implementing a service layer (as described by Martin Fowler) within our current development as a way to process common processes within our system. What are peoples thoughts on a service layer? What examples of process' have people implemented service layers for? What are the benfits/drawbacks etc? We currently...

Need help me w/some code samples of using php to download an attachment from GMail?

I found a number of things on this site but i'm a newb and getting all kinds of errors. The main thing is that accessing Gmail over IMAP, I get a connection error while running the script on localhost. Please advise. ...

PHP flushing output as soon as you call echo

I thought flush(); would work, at least from what Google/Stackoverflow tell me, but on my Windows WAMP (Windows, Apache, MySQL, PHP) system it doesn't work. Is there some PHP setting I have to set to make flush() work? Here's my code: <?php echo "Fun"; flush(); sleep(5); echo "<br>Mo"; ?> The code just outputs all together when t...

PHP developer looking for solutions equivalent to j2ee architecture

I am a PHP developer, I read about J2EE technologies and I want to implement such technologies( n-tier, EJB, JPA...) with PHP and all what coming with ( MySQL, Apache..). ...

Why do Zend Framework Action Controllers have a Suffix?

Hello Stackoverflow, I am quite a new Zend Framework user but I am not new to PHP or Programming. I have been going through the code to try and get to grips with how everything slots together. One of the parts I have been looking at is how classes are Autoloaded in the system. I can see that: Zend_Application_Bootstrap references Zend...

Regex in PHP between /* & */ for preg-match

I am trying to extract all substrings in a string that is between the strings /* and */. I know this will probably need to be done with regular expressions however I'm having a hard time getting the correct regex since the star character is actually used to symbolise repeated characters. I'm am trying to use the preg-match method in PHP ...

WP ecommerce plugin: Show categories and products in tree view

Hi All, I'm setting up a Wordpress site with the WP ecommerce plugin, I have it all setup and ready but I want to display the categories and products in a tree form (i.e. li tags) within the side menu. Has anybody done this beofre - don't mind if I have to whack the code in myself. Any help, much appreciated. Regards Shane ...

Can I use substr() as the needle in in_array()?

$haystack = 'I am a haystack. Hear me rawr.'; $pos = strlen($haystack); $nlen = 1; $needle = array('.', '. '); print_r(in_array(substr($haystack, $pos, $nlen), $needle, true)); I am having trouble figuring out why this is failing. I am trying to see if an array of needles matches the result that substr chooses from the haystack? How ...

PHP - Return an array from a recursive function

Hi all, After two hours of head scratching and googling - i'm stuck! As per the title I'm trying to return an array that is built up as the function loops through. I want to only return the array variable on the else however it will not co-operate. It simply returns as blank away from the function, however within the else I can prin...

How can I include CSS in php?

i want to include my css/stylesheet via php so that... <link rel="stylesheet" href="http://www.mydomain.com/css/style.php"&gt; so that i can than dynamicly change different stylesheets.... how can i do that ...

Parse form textarea by comma or new line

I have a textarea in a form that allows users to enter a list of numbers separated by either a newline or a comma. I need the numbers they entered to be entered into an array. Unfortunately, the code I have does not work all the time. If users enter comma sepated data and a newline then the comma is left in the resulting array. In additi...

How to dynamically generate XML file from MySQL database using PHP

Hi, I am searching for a PHP function that dynamically generates an XML file with data from a MySQL database. It should also update the database if the XML file is changed. ...

Can't work a view, how to bypass it and code it in php instead

I'm new to drupal, and having a tough time getting a view to work (see this question). Since I can't figure out how to do this with Views, and since getting this done in code is usually a piece of code, is there a way I could bypass the Views UI interface entirely and set the view with normal MySQL code? ...

phpmailer AddEmbeddedImage() method attachment problem

Hi all, I have a problem with AddEmbeddedImage() method from phpmailer. I am sending a html email template to users and i have a image as logo, it is working ok, but it also sending an attachment the same image as for logo. Does anybody know how to make this not to send attachment too? Thanks ...