php

[PHP] Initializing class with bad input makes it unusable but object is still existent

If I want to create a new object that needs certain informations like a product id or something like that but the input is bad how can I elegant manage such a case? class Product { function __construct($id) { if(is_invalid_id($id)) { return false; } } } If I initialize it this way I still get an object (since retur...

Why does fopen produce varying files from calls to Twitter, when the file should be static?

Hi, I am trying to get a list of Twitter users using their API. When I query the API in my browser (http://api.twitter.com/1/statuses/followers.xml?screen_name=atomictom), it returns an XML doc with 100 users, as it should. However, when performing the query from my php file: $file=fopen("http://api.twitter.com/1/statuses/followers.xm...

How to avoid looping sql query in php?

What's the best way to make a select in this case, and output it without using nested queries in php? I would prefer to make it with a single query. My tables look like this: table1 id | items | ---|-------| 1 | item1 | 2 | item2 | 3 | item3 | .. | .. | table2 id | itemid | comment | ---|--------|----------| 1 | 1 | co...

How to Stop Wasting Time in PHP

As a programmer, I love developing algorithms. I love to take a problem and work out a clean, efficient, readable, elegant solution. I seem to find, however, that the majority of my time is spent validating and cleaning form data, and passing it along to prepare various SQL statements. Perhaps this is "just the way it is" but I suspec...

Donot getting correct date/time

Hi I have php page in a server, located in US. the code in the page is echo date('Y-m-d H:i:s'); When i take this page, it give a time //eg 2010-10-26 10:20:07 But when i refresh the page on very next second, it gives same date with different time (a huge difference ) //eg 2010-10-26 08:25:58 Can any one tell the reason for ...

How can I store UTF8 in MySQL with PHP, sanitize it, echo it with XML and transform it with XSLT?

I am developing a MVC application with PHP that uses XML and XSLT to print the views. It need to be fully UTF-8 supported. I also use MySQL right configured with UTF8. My problem is the next. I have a <input type="text"/> with a value like àáèéìíòóùú"><'@#~!¡¿?. This is processed to add it to the database. I use mysql_real_escape_string...

php preg replace :: regex

Hi there, If I have a string that looks like my name is {your name here} and I am from {country}. I am trying to use preg_replace to remove the {content} so the string ends up as my name is and I am from . But I can not work out the regex for the pattern. Can someone please help me out? my name is and I am from . is simply a sample ...

VB.NET - Loading box/Catch PHP

Hi, How would I get a box in VB.NET that reads the status of my PHP side? E.g. http://www.youtube.com/watch?v=H8KbDcvUC6w - Look at "sending to shells" in the box all of the text in the box is from a PHP file. How would I get those message to load at that same speed? The video will clear up your minds. Thanks if helped. ...

Email list problem

My sql query to get all the e-mail addresses from my table is as follows: SELECT DISTINCT cEmail FROM tblUsers WHERE cEmail IS NOT NULL AND cEmail LIKE '%_@__%.__%' However, when I insert the list to gmail, it's still saying there are invalid e-mails. There are over 2000 e-mails and hard to go through each one to find out ...

Does Zend have something like {strip} in Smarty?

Smarty has a {strip} function: {strip} <table border='0'> <tr> <td> Hello world </td> </tr> </table> {/strip} Which outputs: <table border='0'><tr><td>Hello world</td></tr></table> I also want to do this in Zend (to reduce the amount of bites send on each request), without installing Smarty. However, I don't want to add ...

using php to generate html and javascript - quote/doublequotes

This php statement works, but is there a more readable way to express it, in terms of quotation marks. $pCode = $row['SIZIP']; echo " <a href='#' onClick='jfFn(\"".$pCode."\");return false;' > " . $pCode . "</a>"; ...

How do I make my shell_exec output into pages?

Hi I am new to PHP and hope someone can help me. Sometimes the output from the executed shell script can be hundreds of lines long, the lines are separated with a <BR> (replaced \n in shell script) for formatted html output. So I need to know how to make the output paginated, I looked at some other similar solutions here but I couldn't...

PHP Output of SQL Query

As of now I have no errors in my program, but I need the primary key for one of the tables for a relation for the following Query. but instead of getting a actual number the value the query is sending back is Resource id #4 Here is my Code: (The query that I'm having issues with is the $sql_branch, is there a function to change the resu...

PDO Request Causing 500 Internal Server Error

This PDO request is not welcomed by my server for some reason. It makes the server throw a 500 Internal Server Error. All of my other PHP files are working fine and I haven't changed any server settings. Strangely though, It seems that when I comment out the line that binds the variable $u, it does not give a 500 error. I am perplexed. ...

how to access mysql link connection resource from zend mysql DB connection object

Here is how i am creating the zend db connection $DB = new Zend_Db_Adapter_Pdo_Mysql(array("host" => "localhost","username" => "root", "password" => "admin123", "dbname" => "user_management")); The problem i have is that in my model files mysql_query have been used to run queries. I want to pass the DB connection from the controller...

PHP Upload Progress Status

Hi guys! I need to show upload status (Total size, curent uploaded size and upload speed) But every script need library and I don'T know how it work (I use XAMPP under Windows)... I have only APC Lib. I tried FancyUpload, but even in the demo I got this error : Error caused a send or load operation to fail (Error #2038) And I tried SWF...

How can i improve this code using Object Oriented Programming?

Is this is far as you would go regarding Object Oriented PHP or can i improve it further by putting HTML into a class? How would i go about doing that? Note: The code below is using a QuickForm by PEAR. Thanks in advance. <?php //MySQL class require_once('database/class.mysql.php'); //Session class require_once('sessi...

What is a good Twitter PHP library other than Zend?

What is a good Twitter PHP Library other than Zend? ...

Change the default path where the web server looks for images

Hey all, I'm trying to change the default path or add a path that the webserver looks for images. I really would really like a solution to do this in PHP and not in htaccess. The most basic example would be trying to "break" the current implementation so say I have a directory with the following: main/ image.png index.php In index...

[PHP] PayPal Payment Callback

I have searched for more than 4 hours now on how to do callback with PayPal after a payment have been proceeded. The thing is, I have a site the sells tickets to a LAN Party, and the only way to pay is with PayPal. Here is my PayPal buy button code: <form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="po...