php

PHP FastCGI SAPI: Reloading PHP Configuration

I am using PHP FastCGI SAPI on my web hosting environment to run PHP applications. To spawn FCGI processes I use spawn-fcgi helper program. My problem is whenever I make a change to php.ini file, I have to kill and respawn each FastCGI server for the new configuration to take effect. Is there a way to reload PHP configuration(ie. php.i...

How accurate is GeoIP and $_SERVER['REMOTE_ADDR']?

I make a website for my girlfriend and she recently wants to know who is accessing her site. So I use the database of MindMax and I got the list and count of access by country. However, after monitoring it for a few days, it is comes to our surprise that there are accesses from some countries which the website is not target to. Of cours...

is it possible to define a class property dinamically in php?

I have a class definition like: class JConfig { var $offline = '0'; var $editor = 'tinymce'; var $list_limit = '20'; var $helpurl = 'http://help.joomla.org'; var $log_path = '/path/to/logs'; // .... } I want to dinamically define '$log_path' I've tried to define a constant outside the class declaration but no ...

PHP using $var = <<< EOM

hi guys, Updating: The php is considering the code beyond the EOM; closing tag. Here is how my script is structured: <?php switch($x){ case "a": $var = <<< EOM; ...the html... EOM; break; case "b": ...some code... break; } ?> And the script is giving erro just after the EOM; Old: I'm using the following code. $var = <<< EOM ...

Access global variable from within a class

Hi, I have the following (stripped down) code: <?PHP class A { function Show(){ echo "ciao"; } } $a = new A(); $b = new B(); class B { function __construct() { $a->Show(); } } ?> With a bit of surprise I cannot access the globally defined $a variable from within th...

PHP/DB pattern question

I have an app that works with an idea of "redemption codes" (schema: ID, NAME, USES, CODE). And example would be "32, Stack Overflow, 75, 75%67-15hyh" So this code is given to the SO community, let's say, and it has 75 redemptions. You redeem it by entering some shipping info and the code. When entered, this check is preformed: if (cod...

keep user logged in when he visit the same page again?

currently im using session to log in the user. but when i close the browser and open it again i have to log in again. how do you keeo the user logged in in lets say 2 weeks. is it through cookies then? ...

mysql_fetch_assoc returning results in the wrong order

Hi, I have the following code: $sortorder = $_GET['sort']; switch($sortorder) { case "modulea": $result2 = db_query("SELECT * FROM {vanqueue_registrations} WHERE isactive=1 ORDER BY `cleanmodule` ASC"); case "moduled": $result2 = db_query("SELECT * FROM {vanqueue_registrations} WHERE isactive=1 ORDER BY `cleanmodule` DESC")...

PHP HTML output

hi, Wich is the correct way to output html inside a switch structure? I've tried both bellow, none work: <?php switch($x){ case "a": $var = <<< EOM; ...the html... EOM; break; case "b": ...some code... break; } ?> OR case "a": ?> ...the html... <?php break; case "b": ...some code... break; } ?> More info: switch ($_REQ...

How to load dynamic image w/php gd library, w/o saving it on server or having src="script.php" ??

I would like to generate a dynamic image from a script, and then have it load to the browser without being persistent on the server. However, I cannot call this by setting the image's src="script.php", since that would require running the script that just generated the page and its data all over again, just to get the final data that ...

Can PHP's glob() do a not wildcard?

I know I can do this glob('/dir/somewhere/*.zip'); but is there a way to return all files that are not ZIPs? Or should I just iterate through and filter off ones with that extension? Thanks ...

Issue with JSON and jQuery Iteration

I'm pretty sure it's an obvious error somewhere on this - but let me explain what I'm donig : I'm calling a PHP file via jQuery as follows : $.getJSON("/phpincs/getbucket.php?awskey="+awskey+"&awssecret="+awssecret+"&bucket="+bucket, function(json){ $.each(json,function(i,item){ $(new Option(item.name,item.name)).appendTo...

Web page installer - database deployment

I have the website written in PHP (Kohana) and MySQL. I want to create the installer which would run all the environment tests and, what is the most important (and the most misterious) for me, will deploy the database. What is more, I would like to choose the prefix of the tables in the database and specify the username and password for ...

how to remove cookie in firefox?

i have created a cookie with: $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; setcookie('cookiename', 'data', time()+60*60*24*365, '/', $domain, false); but how do i delete it? i tried with just switching the + to - but it didnt work. $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP...

why cant i create cookies in Firefox?

I cant create a firefox cookie with following line: setcookie("TestCookie", $value, time()+3600, "/", "localhost"); does someone know why? i have checked the settings in FF and it accepts cookies from 3rd parties and are deleted when they expire. EDIT: i can create now with this line: $domain = ($_SERVER['HTTP_HOST'] != 'localho...

AES, MySql and Headaches

Hello everyone. I am working on a checkout page for an ecommerce site. In said site, people input their credit card information and it is saved to the order in an AES encrypted format. This worked fine when all they supported was VISA. Now that they support MasterCard and Discover (16 digit numbers), it no longer works. The insert q...

How can I create a download link of a PDF that does not require a right click?

Hi, I am working on a website where the visitor should be able to download a pdf file. (There are three links to choose from but that is irrelevant) I wanted to know how to make it so that the visitor can simply click the link and not have to right click > Save (target) As... I am open to PHP and or Javascript solutions. Thanks. ED...

MySQL Query Question.. I give up!

*UPDATE, seems like the answer was given, but the SQL query his erroring out.. can anyone help? See the first answer, i posted the problem there. So to put this simply. I have 3 tables. An "item" table and a "tag" table. Then I also have an "item_tag" table which ties the 2 together. I want to make a query that lists all the items ...

Session and cookie in same PHP file?

Can't I set session and cookie in same PHP file? I get an error message if I set the cookie after I've set session telling me that the header is already sent. If I set session after cookie I get nothing but it seems not to work well. ...

CakePHP: image inside link, want to make link point to image location

I have some images inside links that I want to essentially look like this: <a href="/path/to/img.png"><img src="/path/to/img.png" /></a> Clicking on the link should load the image it contains. I'm trying to use CakePHP's HTML helper to do this, as follows: <?php echo $html->link( $html->image('img.png'), 'img.png', arra...