php

php string-manipulation (clear the "_" and the timestamp)

Hi! I cant find the way how to strip the useless section of my string (read from SQL) I've tried the strreplace and truncate but those was not good at all. I've got a string variable called $stuff if $stuff = 145_timestamp i want to clear the _ and the chars after it. so i want to $stuff be 145 only. Thanks. ...

No progress bar in IE8 while executing the download using PHP

I am giving downloads to user using the PHP code below but when user downloading they are not able to see the progressbar in IE8 when clicked on save button. Please solve this. Thanks in advance. header('Content-Description: Songsbin.com - Downlaod'); header('Content-type: audio/mpeg'); header('Content-Disposition: attachment; filename=...

How to get the absolute path of the calling file in a function that's called in PHP?

in file.php: call()... How to get absolute path of file.php inside call() ? Pay attention that call() may be defined in another file. another.php: function call(){..} file.php: include(path_to_another.php); call(); ...

Which directories does PHP check when including a relative path with include() ?

It's very odd,has anyone ever sum up with a conclusion yet? Sometimes it checks the directory of the included file,too. But sometimes not. D:\test\1.php <?php include('sub\2.php'); D:\test\2.php <?php include('3.php'); Where 3.php is in the same dir as 2.php. The above works,but why?The current directory should be D:\test,but...

"Use of undefined constant CURLOPT_PROTOCOLS and CURLPROTO_HTTP" but it works?

Hi on our dev environment we have show all errors, warnings and notices. I'm getting this: Notice: Use of undefined constant CURLOPT_PROTOCOLS - assumed 'CURLOPT_PROTOCOLS' in C:\notion\implementation\development\asterix\library\ExternalLibs\panda.php on line 69 Notice: Use of undefined constant CURLPROTO_HTTP - assumed 'CURLPROTO_HTT...

[How-to] Make a working xml file in php (encoding properly) to export data from online database to iphone.

Hey guys, I am trying to make an xml file to export my data from my database to my iphone. Each time I create a new post, I need to execute a php file to create a xml file containing the latest post ;) Okay so far ? :D Here is current php code ... but my nsxmlparser gives me an error code (33 - String is not started). I have no idea w...

Is debug_backtrace() safe for serious usage in production environment?

It's functionality is so strong that I worry about its stability and performance. What do you think? UPDATE What I'm doing is this: $old_dir = getcwd(); chdir( dirname($included_file) ); include ( $included_file ); chdir( $old_dir ); Essentially it just does include ( $included_file );,but inside that $included_file...

Why can't I use a constant in a php object?

Why doesn't this work? define("STR_TEST", "qwerty"); class Test { public $arrTest = array( "test"=>"Bla bla bla ".STR_TEST ); } $objTest = new Test(); print($objTest->arrTest["test"]); ...

What is meant by Web Services?

Can anybody tell me what is meant by web services? How do they work? and more information about it. ...

Store database, good pattern for simultaneous access

I am kinda new to database designing so i ask for some advices or some kind of a good pattern. The situation is that, there is one database, few tables and many users. How should i design the database, or / and which types of queries should i use, to make it work, if users can interact with the database simultaneously? I mean, they have...

Sending varibles behind the scenes from PHP to whatever absolute or relative page?

How do I post them to whatever page from here and how can I send these variables to several pages at the same time? //catched those variables within the same page $event = $_POST['event']; $when = $_POST['eventdate']; $where = $_POST['place']; $name = $_POST['name']; $tel = $_POST['tel']; $email = $_POST['email']; send $event, $when, $w...

What's a good PHP Active Record library?

I've been using CodeIgniter for some quite time, and I've been extremely happy with its Active Record stuff. It's great to query the database with it. Recently I've started a new project and I can't use such a framework anymore. Is there a simple PHP Active Record library that does its job and gets out of the way (similar to CodeIgnite...

The whole site is blocked while one page is waiting for blocking operation (PHP, ASP.NET). Why?

Good day! I've found interesting behaviour for both LAMP stack and ASP.NET. The scenario: There is page performing task in 2-3 minutes (making HttpWebRequest for ASP.NET and curl for PHP). While this page is processed all other requests to this virtual host from the same browser are not processed (even if I use different browsers from...

CodeIgniter Project Giving 303/Compression Error

Trying to setup a CodeIgniter based project for local development (LAMP stack), and once all the config file were updated (meaning I successfully had meaningful bootstrap errors for CodeIgniter), I get this error in my browsers: Chrome Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error. Firefox Content Encoding Error: The page...

Code to download this link with PHP curl

This link http://ajaxcontroltoolkit.codeplex.com/releases/view/11121#DownloadId=28808 shows a popup on which one has to agree before being able to download. So how to automate this with PHP curl ? Any existing similar sample code ? ...

mod_rewrite browser trying to get content from non-existant dir

I have my mod_rewrite set up so that it redirects all requests that aren't targeting existing files or directories to index.php?req=* where * is the request. Works all fine but when I send the browser to something like this: http://myurl/A/B/C The browser tries to find all images, stylesheets in the non-existing folder C. How can I m...

Use content of fieldnames in query..

Hi, i have three mysql tables: Table 456 id | binder | property1 1 | b | hello 2 | b | goodbye 3 | a | bonjour Table binder id | binder | tableid1 | tableid2 1 | a | 23 | 456 2 | b | 21 | 456 3 | c | 45 | 42 Table 21 id | property1 | data.. 1 | goodbye | data about goodbye.. 2 | ciao | data about ciao.. So first i want to select in...

Setting custom php include path in .htaccess on mac os x

in /Users/username/Sites/somesite/.htaccess I have AllowOverride All php_value include_path ".:/Users/username/Sites/somesite/inludesFolder:/usr/lib/php" I have also modified /etc/apache2/httpd.conf to AllowOverride All and restarted websharing, but it's not finding the additional include path. I'd like to avoid modifying t...

CodeIgnitor is generating multiple sessions in the database, why?

Ive got a site that does a few ajax calls on page load, now for some reason, codeIgnitor is inserting 4 sessions (I'm assuming for each ajax call) as you load the page. I'm storing the sessions in the database. I'm pretty sure there should only be one session per browser? FF seems to only generate one, other browsers seem to create a wh...

How do I tell regex to match at least x number of alphanumeric?

I have form where user submits field. Field can have letters, numbers, and punctuation. But I want to check to make sure that at least 3 of the characters are letters. How can I regex that? For example, $string = "ab'c"; And I need something like, if (preg_match("/[a-z]{3}/i", $string)) print "true"; else print "false"; Th...