php

php - How to solve this setcookie issues

Hello all, Here is the web structure of my page: 01.<?php // rnlogout.php 02.include_once 'rnheader.php'; 03.echo "<h3>Log out</h3>"; 04. 05.if (isset($_SESSION['user'])) 06.{ 07. destroySession(); // report error here!!!!!! 08. echo "You have been logged out. Please 09. <a href='index.php'>click here</a> to refresh the scree...

Is it possible to let Doctrine 1.2.2 generate getters and setters?

I'm looking for a way to let Doctrine generate getters and setters for me, because otherwise it will call the Doctrine_Record "get" method which costs a lot of time. so is there a chance to do that? ...

Nice piece of PHP code for decorating a wall

We are looking for a way to decorate one or two of our white walls of our new office. For the top floor where PHP developers are working we thought a piece of good looking and interesting PHP code would be fun. Anyone willing to help us out? The available walls: Wall nr 1: http://flic.kr/p/8sKDja Wall nr 2: http://flic.kr/p/8sNGFq ...

Rounding down UNIX time to lower hour in PHP

I have been trying in vain to round down the current time to the lower hour in PHP. Here's what I want to do: 1. Take the current time: $time_now = time(); 2. Round it down to the closest hour: $time_now = $time_now - ($time_now % 3600); 3. Print it using the function date: print date('d m Y H:i', $time_test); But what seems to be happ...

Php code for getting the first frame of a video(flv)

I have using flow player for playing my .flv videos.How i can create a thumbnail from the first frame.Is their any inbuilt Php code for doing this one. Thanks in advance. ...

get the exit message to use it with an object's __destruct method.

$fooinstance = new foo(); /*do something*/ exit('bar'); class foo{ __destruct(){ //get the exit message ("bar") to do something with it } } Hello, I would like to get the exit message to do something with it (for example insert the exit status in a database). Is there a way to do that ? Thanks ...

Display message only for the first page load

I would like to display thank you message after adding comment only for the first page load... The comment form is processed using an external php file and than redirected back to the page. I would like to display some message after the redirection only... What would be the best way to do this using php? ...

encode html in php and decode in javascript

I have some html code I want to store in a database. I need a way to encode it in php so all the special characters don't break the db INSERT (the html can include all sorts of spec chars) and then a way to unencode that at the other end in javascript once i've passed it via JSON so that the html is rendered correctly. IS there any way ...

Tranfer images with cURL

I have 2 servers. And i want to transfer a file from one server to an other with cURL. Can anyone show me a good example of this ? What options should I give to cURL ..... Thx. ...

Detect how much stress the mysql database is currently under with PHP

I am developing a large web app and want it to alter itself dependent on a factor that relates to the stress the database is currently under. I am not sure what would me most accurate/effective/easiest. I am considering maybe the number of current connections or server response time or CPU useage? What would be best suited and possible...

PHP: String not appending

I'm building up a url to execute with curl. the url will call an api for the LMS that I'm using. Before being able to call anything else, you need to receive a token from the LMS to put in the url. I have gotten the token from the api, and I can echo it and it shows up just fine, when I echo the url after appending the token to it, it do...

[PHP] can we pass $_POST value by clicking link?

I need to build some php API to upload an image cross subdomain. Example, upload script located at http://sub.domain.com/upload.php and I neew to upload an image to http://www.domain.com/media/ I read some content at http://www.v-nessa.net/2009/02/09/simple-api-writing-part-i and i suspect that can we pass $_POST value by clicking lin...

Printing data on the side after generating a graph using JGraph library in PHP

Hello I need to generate a report which would include both data and a graph image which is a pictorial representation of the data printed. Now the problem is, the function "stroke" in jpgraph generates the graph, so I get an error if I try to echo any information before the stroke function, and nothing prints onto the browser after the s...

Storing selected option value in Database

I currently have an array I created like this: $regions=array( 1=>'North West', 2=>'North East', 3=>'South West', 4=>'South East', 5=>'West Midlands', 6=>'East Midlands', 7=>'London', 8=>'Yorkshire', 9=>'East England', 10=>'Scotland', 11=>'Wales', 12=>'N. Ireland', ); I will use this arr...

Set -1 to 0 while adding in MySQL

I've got a database using DECIMAL type values for various tests on crude oil. When running these tests you run into certain cases: 1.) Test was run and value is found; 2.) You can definitively say nothing is there (0 in database); 3.) Test was not run (NULL in database); 4.) There is something found, but testing is not accurate enough t...

Which of these two IF Blocks is better coding practice?

User 2 offers to buy an item from User 1. User 1 can accept or reject. If User 1 accepts, then they will both be able to offer feedback about the transaction. I have 2 blocks of IF statements. They both work and do the same thing but which is better coding practice? IF BLOCK 1 checks if which user is there first and then checks if ...

php chown exec() question!

Hi people, I need to write an exec to change owner on some folders on my webserver. This is what I am working with. exec('cd /xxxxx/xxxxxx/public_html/ && chown user.user * -R', $out); Got to be honest Apache is not my bag so kind of stumbling in the dark. Basically I need to change all directories to user and not 99 as they currentl...

An open source Facebook app. for a valid cause :)

Hello all, I own a couple of pages against Child abuse and now I'm developing a Facebook application for fighting against Child Abuse. I'm somewhat a newbie, and I found many wonderful resources on the net, however, I don't seem to find what I really want. I know to build a basic app that accesses a user's basic information(using fb_si...

eregi_replace to preg_replace conversion

I have upgraded my php now i am getting warning messages for eregi_replace Can you please help me in converting following ereg expression to preg? $str = eregi_replace("[[:space:]]+", " ", $str); $text = eregi_replace('<a href=?([^ "\']*)>([^<]*)</a>', '<a href="\\1">\\2</a>', $text); $text = eregi_replace('<a href=(\')?([^ "\']*)(\')>...

Continuing to hide HTML input fields when page refreshes?

On a HTML page there is a filter section consistenting of various drop-downs and textboxes. When the 'type_of_report' drop-down is selected the 'onchange' event will hide all the non-relevant inputs for that 'type_of_report'. The filter criteria is preserved via GET (which I retrieve via PHP $_GET). The problem is that when I submit t...