php

PHP multiline, concatenated strings

Any difference between the two, int terms of speed/performance? $sql = "SELECT * " . "FROM `myTable` " . "WHERE `id` = 4"; $sql = "SELECT * FROM `myTable` WHERE `id` = 4"; ...

Interacting PHP with Google Calendar - which method is better?

Hey everyone, I have written a web application that interacts with Google calendar (adds/edits/updates events). You may have seen one of my many posts about it. I had been struggling with the fact that sometimes I find my application to be slow on performing calendar operations. I have since come to the conclusion that it is not slow d...

mySQL query - show most popular item

I need to find the most popular occurrence of an item grouped by date and display the total of all items along with the name of this item. Is something like this possible in a single query? note: If they are all of equal occurrence (see last 3 rows in Insert) than I can just show at random or the first or last occurrence (whichever is e...

How to pass value to a Html label into php?

I have am trying to pass the value of a label into the php. how should i do that? My HTML looks like: <form action='unsubscribe.php' method='get'> <label for='[email protected]'>[email protected]</label> <input type='submit' value='Unsubscribe me'> </form> How can i get the value of this label passed into my unsubscribe.php? Best Zee...

how to handle php function error

How do i form an if/else statement for a php function failing? I want it to define $results one way if it works, and another if it doesnt. I simply dont want to show an error, or kill the error message if it fails though. currently, i have; if(file_get_contents("http://www.address.com")){ $results = "it worked";} else { $result...

C# String.Format() Equivalent in PHP?

I'm building a rather large Lucene.NET search expression. Is there a best practices way to do the string replacement in PHP? It doesn't have to be this way, but I'm hoping for something similar to the C# String.Format method. Here's what the logic would look like in C#. var filter = "content:{0} title:{0}^4.0 path.title:{0}^4.0 descri...

How do you cut off text after a certain amount of characters in PHP?

I have two string that i want to limit to lets say the first 25 characters for example. Is there a way to cut off text after the 25th character and add a ... to the end of the string? So '12345678901234567890abcdefg' would turn into '12345678901234567890abcde...' where 'fg' is cut off. ...

Problem with using an HTML form in an email.

I'm sending an HTML email which is only going to be opened using Microsoft Outlook. Here's the HTML for the email: <form action='http://server.com/unsubscribe.php' method='post'> <input type='hidden' name='email' value='".$row1['EmailId']."' /> <input type='submit' value='Unsubscribe me'> </form> Here's the code for unsubscribe.php: ...

Which unit testing framework do you use for Symfony?

Which unit testing framework do you use for Symfony? Lime or PHPUnit? What are the pros and cons of using them? ...

PHP, MySQL | Windows vs Linux

Well the title does the explaination. Which one is faster PHP/MySQL on Linux or on Windows. Question 1 I know that MySQL is slower on Windows, because i tried to run a C++ program on Windows to access MySQL, it took a year every time it had to open a connection. When i ported the exact copy into the linux enviornment it was lightning f...

jQuery/PHP and multilingual confirm/alert boxes

Just when I was about to post this question, I came up with an easy solution kind-of-a solution. The problem was that I needed confirmation messages in multiple languages, depending on the selected language by the user. Since I always grab certain information from the HTML, I was trying to do it that way, but got stuck around this point...

To understand a line of PHP

What does the following line mean, particularly the operator .= ? $query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;"; in the code <?php $conn = pg_pconnect("dbname=publisher"); // these statements will be executed as one transaction $query = "UPDATE authors SET author=UPPER(author) WHERE id=1;"; $query .= "UPDATE auth...

To solve a pg_query error message in PHP

My code handler.php ... // independent variables $dbHost = "localhost"; $dbPort = 5432; $dbName = "masi"; $dbUser = "masi"; $dbPassword = "123456"; $conn = "host=$dbHost port=$dbPort dbname=$dbName user=$dbUser password=$dbPassword"; $dbconn = pg_connect($conn); $sql = "SELECT username, passhash_md5, email FROM use...

Multi page form validation with php

Hi, This is my first post, so be kind ; ) I'm wanting to create a multi page form with php. The form will spread over 3 pages, each page will need to validate on the data entered into the form on the client (using jquery validation) and if javascript is disabled, on the server, where error messages need to be displayed beside the rela...

What is the correct/safest way to escape input in a forum?

I am creating a forum software using php and mysql backend, and want to know what is the most secure way to escape user input for forum posts. I know about htmlentities() and strip_tags() and htmlspecialchars() and mysql_real_escape_string(), and even javascript's escape() but I don't know which to use and where. What would be the safe...

checkdnsrr always returns false on windows

I am using checkdnsrr on Windows with PHP 5.3 and it always returns false. dns_get_record, however, works. echo ("test.com dns check: ". checkdnsrr("test.com","NS")); //false!! print_r(dns_get_record("test.com",DNS_NS)); //returns the right data Any ideas? ...

Problem with fetching a BLOB column in PHP + MySQLi

Here's the code: $conn = new mysqli('localhost', 'user', 'password', 'db'); $stmt = $conn->prepare('select Data from sessions'); $stmt->execute(); $x = 234; $stmt->bind_result($x); $stmt->fetch(); var_dump($x); This outputs: string '' (length=0) In fact the table contains exactly one row and the blob column contains some valid ...

PHP or Javascript which to learn first ?

As the title says in your opinion which should I learn first PHP or Javascript. I am going to learn both but which order do you feel I should learn them in? ...

Having trouble allowing people to BUMP a unique entry in table...

So, my table has a bunch of codes in it and I don't want more than one of the same code in the table so I have it as "UNIQUE." But, at the same time, I want them to be able to bump their code once every hour. function some_more_custom_content() { $output="<BR>"; ob_start(); if ($_REQUEST['code'] != "") { $code = $_REQUEST['code']...

Convert time in PHP or Javascript?

I am curious which is the best way to convert time like this 2008-04-23 into 1 year and 3 days ago I currently do this in PHP but I am finding a lot of sites do it in javascript, including Stackoverflow What do you think is the best way, it seems offloading it to the browser with javascript would just slow your app down, yes the big bo...