php

[Doctrine 1.1] Using moveAsLastChildOf to move nodes

For all of you who work with Doctrine, I've a question related to moveAsLastChildOf(). I'm using Doctrine 1.1.6 and Symfony 1.2 I have a nested tree, with lots of elements. I want to delete an element of the tree, so first I have to move all its children (and descendants) to its parent; and then delete it. I do the following: // Get th...

Increment value in mysql update query

Hello. I have made this code for giving out +1 point, but it doesn't work properly. mysql_query("UPDATE member_profile SET points= ' ".$points." ' + 1 WHERE user_id = '".$userid."'"); the $points variable is the user´s points right now.. I want it to plus one to it.. so example if he had like 5 points, it should be 5+1 = 6.. but it do...

Php Alphabet Loop

<?php $string = "hey"; foreach(range('a','z') as $i) { if($string == '$i') { echo $i; } } ?> Why is this not working? please tell me. ...

JS/php add for every minute.

Hello. What i want to do is that every user gets 1 points every minute. Now i have the php code in the addpoints.php, and then i have tried myself with jQuery javascript: function addpoints() { var userid = document.getElementById('user_id_points'); var postFile = 'addpoints.php?userid='+ userid.value; $.post(postFile, function(...

0 in switch case?

Hello! Sorry for maybe dumb question, but i have HUGE problem with one case when i have some int variable with value of 0(zero). switch ($starost_vozila){ case (0): switch ($podaci['tip_motora']){ case ("motor1"): $eko_taksa = 485; ...

How to shorten a string without slicing through a word while keeping within a character limit in PHP

Possible Duplicate: How to Truncate a string in PHP to the word closest to a certain number of characters? How can I shorten a string to a maximum of 140 chars without slicing through a word. Take the following string: $string = "This is an example string that contains more than 140 characters. If I use PHPs substring functi...

Array Loop - get the first value into a foreach loop

I have an array, and I want to get the first value into a foreach loop. then send that value to a function. This does not work foreach ($frequency as $i) { showphp_AlexVortaro (getphp_AlexVortaro ($frequency[$i])); showphp_Smartfm(getphp_Smartfm($frequency[$i])); } ...

MySQL query optimization

Hello, $res (array)-> (count 50 (!) ) Example: ( [1] => Array ( [artistname] => Lady GaGa [songname] => Love Games [duration] => 3:31 [url] => 7e91a5ca16ae [server] => 3 ) [2] => Array ( [artistname] => DJ Layla [songnam...

Has anyone integrated Fedex web services into their website?

I have to set this up so that users can make labels, and track shipments, can someone outline the steps of how this works, including any interaction I need to do in regards to testing and contacting Fedex support, any special keys, gotchas? ...

How to implement communication between Java client application (Android) and PHP server application ?

I have a simple Java client application (Android app). I have to write a PHP server application which receives a request from the Java client application to write some data to a MySQL database or read some data from the MySQL database. It should respond with a status message (Write failed/success) or the data requested respectively. How...

How coarse grained should the model be in an MVC framework?

Hello all, I have been reading a few questions previously asked and I haven't come across one that answers my question in "black and white" for me! So, apologies if this is repetitive. The question is probably similar to asking, "how long is a piece of string" but bear with me! For a registration system, I have a user model with functi...

Syntax error when using isset() method.

Probably an uber-newbie mistake. Here's my code: <html> <body> <?php if(isset($_POST["firstName"] && isset($_POST["lastName"]))){ $firstName = $_POST["firstName"]; $lastName = $_POST["lastName"]; echo $firstName; } else { echo "First name was not written in, you suck!"; } ?> </body> I'm ge...

Use $_POST["x"] directly or to copy to a local variable and then use?

Consider the following pair of snippets, both do the same essentially. <html> <body> <?php if(isset($_POST["firstName"]) && isset($_POST["lastName"])){ //I'm copying the POST variable to a local one. $firstName = $_POST["firstName"]; $lastName = $_POST["lastName"]; echo "<h1>Thank you for taking the census!<...

Facebook Mobile Authorization

I am trying to make a Facebook Connect web app more "mobile friendly". I am currently able to allow iPhone users to log into the site using the normal Facebook Connect PHP libraries. Here is the issue: Using my iPhone I am able to log in successfully. However this leaves 2 Mobile Safari tabs open: the site and the cross domain helper fi...

Switch character case, php

How can i swap around the case of the characters in a string, for example: $str = "Hello, My Name is Tom"; After i run the code i get a result like this: $newstr = "hELLO, mY nAME Is tOM"; Is this even possible? ...

How to do an if statement on a function in PHP?

I just realized that you can't just use an if statement on a function, for example this doesn't work: function sayHello() { echo "Hello World"; } if(sayHello()) echo "Function Worked"; else echo "Function Failed"; I also saw that a function can't be put as the value of a variable. So how can I do an if statement to check ...

Xdebug with PHP 5.2 on 64-bit Windows 7?

I would like to install Xdebug (http://xdebug.org/) on my 64 bit Windows 7 machine to debug Drupal code running on PHP 5.2. The Xdebug download page does not provide a download for a 64 bit version compatible with PHP 5.2. Many Drupal modules are not compatible with PHP 5.3, so it is not an option to switch to a later version of PHP. W...

How to read a web page in PHP

I'm new to PHP and trying to save some web pages to text files using PHP scripts. Do you know any PHP script to load a web page into a file buffer and remove HTML tags? ...

POSTing a PHP variable as a value in a form

I have an html form consisting of just radio buttons. The 2nd line of the following is in a loop, therefore assume there are multiple radio buttons. The value of each radio button printed out is a PHP variable. <form action='delFile.php' method='post'> <input type='radio' value=" . $row['fileName'] . " name='del' /> <input type='submit'...

Will using a substring of an MD5 hash like this be unique enough?

What I am trying to do is create a 12 character id for articles on my website similar to how youtube handles their video id (http://www.youtube.com/watch?v=53iddd5IcSU). Right now I am generating an MD5 hash and then grabbing 12 characters of it like this: $ArticleId = substr(MD5("Article".$currentID),10,12) where $currentID is the nu...