php5

PHP storing db queries in an include file how?

Hi, I'm just learning PHP and I'm trying to figure out how I could store my database queries in a separate file either as part of a class, method or just as simple variables. For example: I have a query that looks like this: $checkuser = mysql_query("SELECT UserName, Email FROM users WHERE UserName = '$user...

php-expect from webpage

Hi everyone, I have a question that has been bugging me recently i wanted to write a webpage that will use the php-expect to SCP an image from another server and then display it in an image TAG here is my code <?php // Copies file from remote host: ini_set ("expect.timeout", 30); $stream = fopen ("expect://scp user@server:/export/ly...

Google Calendar EventId issues (PHP Api)

Hello All, I've been working with the PHP api for google Calendar, and have been getting quite frustrated. I downloaded the zend package with all the libraries from google's page, and have been working off the provided code to make sure it can meet my requirements. The issue I'm running into involves getting an event back from the sys...

PHP move_uploaded_file/copy issue

Hi, Interesting issue I seem to have come across. I have a form that uploads an image and stores the value in a database table. The form uploads the image file OK and makes it available for processing. The issue is as follows; using move_uploaded_file to the specified directory does not work, however using copy() to this directory d...

Distribute web traffic in X time.

I have different sources of web traffic and I serve ads to that traffic, now I need to code something to distribute for example X unique hits in Y time for ad with id Z. I want to be able to send X amount hits to an ad x hour, but I don't want to send all those hits in the first 10 minutes, and then wait 50 minutes to send traffic again...

how replace <tag value="value"> to $tag['$thepreviousvalue'] with regexp

Hello there i've finally made a good perfect language system and now am trying to fix my templates system to work with this new language system =P i want to replace to $tag['$thepreviousvalue'] so i made the following code preg_replace("/<LANGUAGE value=\"^[a-zA-Z0-9_]{1,}$\">/si", ''. $langvals['$1'] .'', $data); but it doesn't work...

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

i am trying to develop a job site using jobberland scripts. but on connecting to server the above error shows on all the pages.can u help me with the fix please. is the problem with scripts or with databases(as some sites have explained while i searched on this query) ...

How can you read QR Codes in PHP?

Is there a plain PHP implementation for decoding QR codes? I have a faux-smartphone. One of those phones that parades as a smartphone but that I can't download any apps for, and I want to create an email service to where I can take a picture of a QR code, MMS it to this email, and the email returns what the QR code contains. However, ...

Count on Zend_Db_Select

Say I have a random zend_db_select object. How can I perform a count on that object, so I know the amount of items that meet the query. I tried the following: $data->TotalRecords = $select->columns(new Zend_Db_Expr('COUNT(*)'))->query()->fetch(); But this gives me the following error: Message: No table has been specifiedfor the ...

Flash to image script

Does anyone know of a script, preferably PHP-based that will allow conversion of a static flash to an image? ...

How do you iterate through current class properties (not inherited from a parent or abstract class)?

I know that PHP5 will let you iterate through a class's properties. However, if the class extends another class, then it will include all of those properties declared in the parent class as well. That's fine and all, no complaints. However, I always understood SELF as a pointer to the current class, while $this also points to the curr...

php process - one after another - simulating threading

I have a report generation functionality. Export to csv or txt . For each month it will be 25000 records each row with 55 columns. For yearly it will be more than 300000!! i try to add memory limit ,but i dont think its good!! Anyway now its 128M. My expectation I will split the date range selected by user into a range of 25 days or 30...

My foreach loop inside a table is not running

Ok so basically I have a a foreach inside a foreach running through a multidimensional object.. Everything works 100% however inside the second foreaech none of the data will display unless I remove the tags outside of the foreach. Does anyone have an explanation?? I have removed most of the code to simplify it a bit also. <?php ...

Music playlist via PHP. json_encode() array limit?

Hola! Im using PHP to create a playlist. Two random songs are chosen from a directory, and their name and location are stored in an array and then written to a file via json_encode(). $arraySongs[] = array('name' => $songName , 'mp3' => $webUrl); This works great. I can make a very long playlist, two songs at a time. Id also like to r...

How to use php code in a template in MovableType 5?

How do I embed/execute php code in a MovableType 5 template? ...

Real world abstract class usage simple samples

Hello, Any real world simple samples of using abstract class? I'm trying to get in PHP's OOP, but I still can't understand - why abstract class should be used and when (Yes, I know that it's impossible to create abstract class instance, only instance of class inheriting it). Thank you ...

What is the best method of cleaning query strings?

What is the best and method of ensuring that $page and $getVars are clean and safe? //fetch the passed request $request = $_SERVER['QUERY_STRING']; //parse the page request and other GET variables $parsed = explode('&', $request); //the page is the first element $page = array_shift($parsed); //the rest of the array are GET statements...

Restrict access to page with PHP

This seems really simple, and I see a lot of documentation about it, but I can't get it to work. Basically, I have a page "download-software.php" that we want only to be accessed from "download-registration.php" On the second page "download-registration.php" I have this: <?php session_start(); $_SESSION['authenticated'] = 'yes'; ?> ...

Expand on Restricting access with PHP

Ok, with some help I got this to work. I needed to restrict access to "download-software.php" to users who came from "download-registration.php" - a form that's action, if the form validates sends you to "download-software.php" with this: on "download-registration.php" <?php session_start(); $_SESSION['authenticated'] = 'yes'; ?> ...

How to reinstall a LAMP server?

I want to reinstall the whole LAMP server under Debian Lenny. This means, using 'apt-get remove' is not enough, I want to remove completely all components, and start again. I tried but files are always there so I can't make a new configuration for everything. What can I do? Thanks! ...