php

Foreach loop returning null values in PHP?

Hello, I have a pretty simple problem. Basically I have an array called $list that is a list of titles. If I do a print_r($list) I get these results: Array ( [0] => Another New Title [1] => Awesome Movies and stuff [2] => Jascha's Title ) Now, I'm running a foreach loop to retrieve their values and format them in an <ul> like so......

Getting Postfix to process the mail queue on Mac OS X

I'm in the process of getting Sendmail/Postfix setup so that I can send and test my PHP scripts when using the mail() function. I've got to the point that when I run the mail() function in PHP, the script executes without any errors and the mail is sent to my mailq but it then does not get processed and simply times-out with a message o...

In PHP: How to call a $variable inside one function that was defined previously inside another function?

I'm just starting with Object Oriented PHP and I have the following issue: I have a class that contains a function that contains a certain script. I need to call a variable located in that script within another function further down the same class. For example: class helloWorld { function sayHello() { echo "Hello"; $var = "...

some confusions to singleton pattern in PHP

Hi all, In my team I've been told to write resource class like this style: class MemcacheService { private static $instance = null; private function __construct() { } public static function getInstance($fortest = false) { if (self::$instance == null) { self::$instance = new Memcach...

What to use instead of if(isset($_POST['submit'])) for this.form.submit()?

I want to run a particular block of PHP if the user submits a form. It works if I use a submit button with name="submit" and: <?php if(isset($_POST['submit'])) { code to run } ?> I don't know anything about javascript, and I want the code to run if the user changes a dropdown menu. If I make the first line of the dropdown <select n...

Problem with passing data to view in codeigniter code.

Hello, I have a codeigniter code that is working on local Apache installation. But it does not work on Godaddy Hosting. I have got other similar views and controllers which are working on Godaddy. Following is the code. I have pasted only relevant code. Controller: function index() { $this->load->model('Feedmodel'); $data['posts...

highlight the word in the string, if it contains the keyword

how write the script, which menchion the whole word, if it contain the keyword? example: keyword "fun", string - the bird is funny, result - the bird is * funny*. i do the following $str = "my bird is funny"; $keyword = "fun"; $str = preg_replace("/($keyword)/i","<b>$1</b>",$str); but it menshions only keyword. my bird...

Doctrine: textarea line breaks & nl2br

Hi, I'm pulling my hair out with something that should be very simple: getting line breaks to show up properly in text that's returned from the database with Doctrine 1.2 I'm saving a message: $body = [text from a form textarea]; $m = new Message(); $m->setSubject($subject); $m->setBody($body); $m->save(); Query...

Cakephp, Retreive Data for HABTM Models using find

I am new to cakephp and I'm trying to accomplish something that should be relatively easy. I have 2 models projects & categories bind by HABTM relationship. I am trying to perform the following query -> find all projects that belong to a category $projects = $this->Project->find('all', array('conditions' => array('Category.slug' => $ca...

PHP parsing XML file with and without namespaces

I need to get a XML File into a Database. Thats not the problem. Cant read it, parse it and create some Objects to map to the DB. Problem is, that sometimes the XML File can contain namespaces and sometimes not. Furtermore sometimes there is no namespace defined at all. So what i first got was something like this: <?xml version="1.0" e...

Problem with PHP & SQL Query

I have a problem in php code inserting values into database (I use PHPMyAdmin). My DATABASE has 3 tables: Member with this fields: MemberID, MemberName Room with this fields: RoomID, RoomName Join with this fields: MemberID, RoomID The idea is to join the member in the room. My query was mysql_query("INSERT INTO join (RoomID, Mem...

Get images from a URL and retrieve them all to select the one which is the biggest.

I want to open a URL and RegEx all the image's URLs from the page. Then I want to cURL all of them and check what size they have. In the end I want to get the biggest one. How do I do this? ...

REGEX (.*) and newline

How can I fix this? REGEX: //REGEX $match_expression = '/Rt..tt<\/td> <td>(.*)<\/td>/'; preg_match($match_expression,$text,$matches1); $final = $matches1[1]; //THIS IS WORKING <tr> <td class="rowhead vtop">Rtštt</td> <td><img border=0 src="http://somephoto"&gt;&lt;br /> <br />INFO INFO INFO</td> </tr> //THIS IS NOT WORKING...

How do I stand out with my PHP skills?

I've been developing with PHP for 3 years using PHP frameworks. I want to be a team lead someday that's why I'm asking you guys, how would you suggest that I improve skills on web architecture more? How do I increase my PHP skills? What resources (books or sites) should I read? What more can you guys suggest? What rituals should I do...

Anything wrong with this php code?

1st I have to say I know nothing bout php. I was actually doing my AS3 guest-book and through parts of tutorials from Activetut, I managed to come out a flash guest-book. So the problem now I'm facing is the guest-book could only inject 1 XML data and it will always clear off the old 1, while the flash is still caching on the old XML fil...

grabing data from url

i have a task - i must grab some data from the URL. the link is http://cba.am. the data, i want to take, are in the some table, and i have the only one identifier, to reach my wanted data, it's the word "usd", which writes in that table(html)! i've written the following script, and it works! but i never heard how more experienced program...

sending email in php unable to use HTML tags

I am trying to send an email through the result sets generated in MySQL in PHP This is the code. <?php $txtMsg = '<table><th>Name</th>'; $txtMsg = ''; mysql_connect("localhost", "root", "pop") or die(mysql_error()); mysql_select_db("jpd") or die(mysql_error()); $oustanding = mysql_query("select Name from results") or die...

Problem with PHP & MySQL

I wrote this statements but it is not work :( ... can you tell me why? HTML: <form action="join.php" method="post"> <label name="RoomName">Room1</label> </form> PHP: $roomName = $_POST['RoomName']; $roomID = "SELECT RoomID FROM rooms WHERE RoomName = $roomName"; EDIT: thanks but in my work the user does not have the ability to ed...

16 bytes binary form of canonical uuid representation in php

Hi guys, how can I get 16 bytes binary form of the uuid from its string/canonical representation: ex:1968ec4a-2a73-11df-9aca-00012e27a270 cheers, /Marcin ...

With PHP and AJAX, Can two clients inter-exchange data without MySQL?

Hi, Let's assume I'm developing a AJAX, PHP chess game. During the game, one movement of a player will be notified to the another but we are not saving that information. Normally, we used to store in MySQL every time a player makes movement and show update position to another player. What I want is to reduce MySQL load as much as possibl...