php5

Hanging request ram issue

I would like to provide a PHP hanging request that will stay open until new events exists, at which point it will immediately return back JSON encoded data to javascript client. Connection -> wait for events (check, sleep, check, sleep, etc) -> event is detected -> send events back -> close request. CPU load is no issue with this confi...

Best way to connect to mysql with php objects using mysqli object

If I have in my php app an object that connects to the database, lets say I am using mysqli as on object for my database transactions. example: $dbase = new mysqli('localhost','dbuser','dbpass','dbname'); $oresult = $dbase->query("SELECT `field` FROM `table` WHERE `otherfield` = 12;"); if($oresult->num_rows > 0) { $row = $oresult->...

preg_replace removes second backslash at start of line

Consider this: $sServerPath = "\\\\nlyehvedw1cl016\\projects$\\ARCLE_SW_SVN\\"; $sSVNParentPath = $sServerPath."svn\\"; $bla = " authz_module_name = TEST_TestRepos repository_dir = bla W"; $sSVNParentPath = $sServerPath."svn\\"; $sReplaceBy = "repository_dir = ".$sSVNParentPath.$sProjectName."\n"; echo $sReplaceBy; echo preg_replace ...

Enable the "redeclare" for PHP5, with .htaccess or php.ini

Hi friends, serious problem with an angry client :( i have an issue about "Cannot redeclare variable" etc. i had a website working on PHP4 then moved to PHP5 and i have this error: Fatal error: Cannot redeclare CSQLAdmin::$functions in /blabla/lib/sqladmin.php on line 45 I tried to clear the second declaration at the file, and it fi...

How do I make a check point for my script? And....

Okay, so I am basically making a script to pass post data using cURL. Using my previous example in another question, I will be passing my ever growing list of phone numbers. However, I can only submit 20 phone numbers a day at the max. So how can I make a check point for my script to find out where it last stopped (which phone number was...

IP Filtering/Matching by host mask with PHP & MySQL

Hey there, I'm wanting to do something similar to this: http://stackoverflow.com/questions/594112/matching-an-ip-to-a-cidr-mask-in-php5 Except, I want to store a list of disallowed IP/Masks in a MySQL table and check for a match. Just like the example in the link, something like '10.2.0.0/16' would be a row in the table and then I wan...

getenv("HTTP_XXX) return nothing

Hello! Why this code return "" : $ip = ""; if(getenv("HTTP_CLIENT_IP")) { $ip = getenv("HTTP_CLIENT_IP"); } elseif(getenv("HTTP_X_FORWARDED_FOR")) { $ip = getenv("HTTP_X_FORWARDED_FOR"); } else { $ip = getenv("REMOTE_ADDR"); } Environment: W2003EE, IIS 6.0, PHP 5.2.9 (ISAPI) $_SERVER is a built-in PHP variable. getenv() look...

PHPUnit, Testing "Behaves Like A..."

I have a series of PHPUnit tests to validate a class, "Class A". I have another class, "Class B" which extends Class A. Is there a good way to test that "Class B passes Class A's tests", or in other words "Class B behaves like Class A" without duplicating the test code? I could test for the extends (using instanceof), but that seems li...

PHP Concatenation becomes NULL

When I run this code, About half-way through the concatenation loop, $xml becomes null and remains null throughout the rest of the concatenation loop. Has anyone else ran into this? Or see why this is happening? $xml = ''; foreach($this->currentColumns['unknown'] as $column => $value) { $xml .= "<columnName>"; $xml .= $column; ...

Why does $$var['namedIndex'] = 'test' doesnt work?

In PHP you can you $var = 'title'; $$var = 'my new title'; and it works fine. But when you try to use it with array, it doesnt work and no errors are reported. $var = 'title'; $$var['en'] = 'my english title'; $var = 'description'; $$var['en'] = 'my english description'; Thanks for the help [EDIT] If I do $$var = array(); array_pu...

PHP fmod problem

<?php $i = 1; $y = 5; ?> <?php while (have_posts()) : the_post(); ?> <?php if (fmod($i, $y) == 0) { echo '<tr>'; } ?> What i'm doing wrong? I want every 5 time to show the <tr>,any help? ...

[PHP]: Why page is not redirecting?

In the following code, the "header:" line is giving problem. $q = mysql_query($a) or die(mysql_error()); $row = mysql_fetch_array($q); $ValidationResponse = "false"; if ($_COOKIE['user_name'] != "") { while ($row) { if ($_COOKIE['user_name'] = $row['username']) { $ValidationResponse = "true"; brea...

How do you past post data without the name value for inputs?

passing post data using cURL requires that the name of the input. However, I was wondering how can you do it if the input was not assigned a name? curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" http://www.formpost.com/getthis/post.cgi ...

How to parse complex XML file using PHP ?

Hello All, I am a .net developer, now trying to learn PHP for the first time. .Net provides API to parse complex XML files. How one can achieve this using PHP? I have some samples which uses basic XML files. I am using XML structure having attributes included in it. Please help to achieve this. Thanks in advance. :) ...

Create a blurb from text from a database (similar to "read more")

Hello, I am trying to cut text from a database off if <!-- break --> is found then only show what is before the break. I currently have this code //get the description before the more link $project_blurb = htmlspecialchars_decode($project_data['p_desc']); if (strstr($project_blurb, '<!-- break -->')) { $project_blurb = ex...

My database doesn't insert immediately

Hi, I am a trying to apply Test Driven Development to producing a web page and am having trouble using my database. I am developing using Cake 1.1, PHP5 and SimpleTest to unit test. My problem is that I have a test that: Inserts a row using a direct SQL statement Tests if that row was inserted (by using a function in my main program....

cURL help with PHP

I am playing with cURL, and I am having trouble getting it to work. I want the cURL script to post the data on that form so I can see the posted data in results.txt. Here is my form script and then my cURL script after. I changed the $url before posting here. Edit: The problem is, it's not posting the data. I ran the cURL script, and ch...

Using parameters from file into function.

I have a settings.php file with parametric variables and a functions.php with well, some functions. functions.php uses some parameters from settings.php and also, functions.php is required once inside index.php. Well, for some reason, when trying to execute index.php the functions can not read the parameters from settings.php in this me...

Saferpay Implementation

Sorry for my bad english. I have to implement saferpay in my project. I have two php file for now checkout.php success.php When I execute the checkout.php file it redirects to success.php and then it shows an error. I have tried to remove this error but I'm unable to remove it. Please tell me any solutions by which I can remove t...

PHP - Is this a good method to prevent re-submission?

This is related to preventing webform resubmission, however this time the context is a web-based RPG. After the player defeats a monster, it would drop an item. So I would want to prevent the user from hitting the back button, or keep refreshing, to 'dupe' the item-drop. As item drop is frequent, using a DB to store a unique 'drop-trans...