php

PHP fmod problem

<?php $i = 1; $y = 5; ?> <?php while (have_posts()) : the_post(); ?> <?php if (fmod($i, $y) == 0) { echo '<tr>'; } ?> What i'm doing wrong? I want every 5 time to show the <tr>,any help? ...

Is this a bad pattern? (Switch inside for/foreach loop)

I find myself writing code such as: foreach($array as $key => $value) { switch($key) { case 'something': doSomething($value); break; case 'somethingelse': doSomethingElse($value); break; } } Is there a better way to go about this? Seems dirty to me, but I might j...

Parsing vCards on web pages into a MySQL DB

I have a client who is using a separate vCard on a separate page. These are being pasted into a wordpress text field. (Not the most efficient way to maintain a list of people, but I won't editorialize after the fact.) My mission is to write something to parse through all the addresses in the vCards and to dump the information into a c...

How do I figure out the smtp_port for my localhost?

I am using a script that is sending out emails and I am receiving the following error: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\bin\php\php5.3.0\PEAR\Mail\mail.php on line 125 How to i figure out the stmp_po...

Syntax error when in a class but not out in the open?

When I do: class MyClass { public $copy = file_get_contents('somefile.mdown'); } I get: PHP Parse error: syntax error, unexpected '(', expecting ',' or ';' \ in /file.php on line 25 I'm new to classes in PHP, but not to OOP. I can, of course, just do file_get_contents outside of the class and all is well. What's up with this? ...

Counting the number of letters in a word by PHP

I want to create an array which has two columns. The output should contain only the existing letters in the word with their amounts. The wanted output of the following code a 3 s 2 p 1 What is wrong in the following PHP code? <?php $alpha = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','...

Need some help with XML parsing

The XML feed is located at: http://xml.betclick.com/odds%5Ffr.xml I need a php loop to echo the name of the match, the hour, and the bets options and the odds links. The function will select and display ONLY the matchs of the day with streaming="1" and the bets type "Ftb_Mr3". I'm new to xpath and simplexml. Thanks in advance. So far...

[PHP]: Why page is not redirecting?

In the following code, the "header:" line is giving problem. $q = mysql_query($a) or die(mysql_error()); $row = mysql_fetch_array($q); $ValidationResponse = "false"; if ($_COOKIE['user_name'] != "") { while ($row) { if ($_COOKIE['user_name'] = $row['username']) { $ValidationResponse = "true"; brea...

PHP+MYSQL: Problem with Update query

Hi, I'm having problems running this query. I keep on getting the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read = 'readd' WHERE user_id = '1' LIMIT 1' at line 1 The code $conn = mysql_connect('localhost', 'admin', 'root') or die(m...

Problem with Advancedatagrid in tree using flex3?

In my application i used Advance datagrid . On this arraycollection based to binding the dataprovider like <mx:dataProvider> <mx:HierarchicalData id="GC" source="{groupList}"/> </mx:dataProvider> my arraycollection like private var groupList:ArrayCollection = new ArrayCollection([  {Country:'India', children:[      {Country:'S...

Automate database table creation from within CakePHP framework

I'm trying to write a webapp with CakePHP, and like most webapps I would like to create an installer that detects whether the database has been initialized and, if not, executes the installation process. This process will be entirely automated (it assumes the database itself already exists, and that it is granted full administrative acc...

how to display data in two column with php

How can I display data in two columns? <?php $query = "SELECT * FROM `release` WHERE artist_id = '$rcode' AND label_id = '$id'"; $result = mysql_query($query); $tr_no = mysql_num_rows($result); while ($info = mysql_fetch_array($result)) { ?> <div> <table style="width: 100%"> <tr> <td ><img src="../artwork/...

What http status code is supposed to be used to tell the client the session has timed out?

In a webpage, it uses YUI connection manager/datasource to send AJAX requests to the server, if the session (which contains the info on whether the user has been authenticated) has already timed out, those ajax responses that can only be viewed by authenticated users should return an http status code, telling the client that the session ...

PHP - How to get all text after given phrase?

How can I get everything from $string after "<div class='partFive'>"? Thanks! ...

How can I make the URL search engine friendly?

I want to cahange mysite.com/profile.php into mysite.com/profile I wrote the htacess file as RewriteEngine On RewriteRule ^profile/?$ profile.php [NC,L] and placed in root directory. It doesn't work. I use the apache server. What is wrong with my program? ...

Double While loop not working

Based on advice that I have been given on StackOverflow, I tried the query below but it did not work. I'm trying to get a list of the 25 most recently-added values for "site" in the database, regardless of what table they are in. The code below give the following error: Warning: mysql_fetch_array(): supplied argument is not a valid My...

[PHP/JavaScript]: How to call a JavaScript function through PHP and fetch value returned?

I want to call a JavaScript function through PHP and store the returned value in a PHP variable. How to do this? ...

Last Five Pages Visited Cookie with php+jquery

how to show Last Five Pages Visited Cookie with php jquery. ...

How can I find a date after certain weeks?

Hi, I need to find a date after a certain number of weeks. For example, if the start date is Saturday, 31 October 2009, and if I choose 16 weeks then I need to find the date after sixteen Saturdays. Thanks in advance. ...

Using associative array values from within the same array

I'm trying to access an associative array's key and value from within the same array. If I have 3 pairs in my array. Can I use the value of let's say the values of something and other within the third one another? $gar = array("something" => "something value", "other" => "other value", "another" => something...