php

How do I get the byte values of a string in PHP?

Say I have a string in php, that prints out to a text file like this: nÖ§9q1Fª£ How do I get the byte codes of this to my text file rather than the funky ascii characters? ...

Simple RegEx PHP

Since I am completely useless at regex and this has been bugging me for the past half an hour, I think I'll post this up here as it's probably quite simple. <a href="/folder/files/hey/">hey.exe</a> <a href="/folder/files/hey2/">hey2.dll</a> <a href="/folder/files/pomp/">pomp.jpg</a> In PHP I need to extract what's between the <a> tags...

geoip + pecl + 64 bits box

Has anyone tried to install geoip over pecl on a 64bits box? I can install geoip just fine using these commands on my 32bits fedora box. I can't on the 64bits version. Any ideas why? yum install make gcc cpp gcc-c++ glibc glibc-headers php-pear php- devel geoip geoip-devel pecl install geoip => on the 64bits version it breaks here wi...

Qcodo vs. CakePHP vs. Zend

I have some exposure to CakePHP and think it is a great framework. Then, I run into this thing called Qcodo. It is another PHP Framework. I've been hearing Zend alot. They all seem very neat, but I'm wondering what are differences between all these frameworks. Before I waste too much time learning another framework, does anyone know p...

mysqli_use_result() and concurrency

According to the documentation at mysqli_use_result One should not use mysqli_use_result() if a lot of processing on the client side is performed, since this will tie up the server and prevent other threads from updating any tables from which the data is being fetched. Does this only pertain to myISAM tables or also for InnoDB? ...

Problem with inserting an image in a form using GD!

Hi everybody, I'm trying to develop a captcha class for my website everything was doing fine until I tried to embed the image generated with PHP GD inside my subscription form! Here is the code of my class: <?php //captcha.php header("Content-type: image/png"); class Captcha { // some attributes bla bla public function __con...

Zend framework (1.7.5): how to change controller directory

Using Zend Framework I want to use controllers stored in a directory which is not default. What I'm trying to achieve is that if the requested path begins with admin/ controllers/admin is used, with layout/admin and views/admin etc. How would I go about achieving this in a reasonably graceful manner? ...

PHP expects T_PAAMAYIM_NEKUDOTAYIM?

Does anyone have a T_PAAMAYIM_NEKDOTAYIM? ...

Improving cURL performance (PHP Library)

Here is a brief overview of what I am doing, it is quite simple really: Go out and fetch records from a database table. Walk through all those records and for each column that contains a URL go out (using cURL) and make sure the URL is still valid. For each record a column is updated with a current time stamp indicating when it wa...

How do I properly sanitize data received from a text area, when outputting it back into the text area?

A user will input text in a textarea. It is then inserted directly into a mySQL database. I use trim, htmlentities, mysql_real_escape_string on it and I have magic quotes enabled. How should I sanitize it when outputting that data back into a textarea? Thanks for your help. I've never been too sure on the correct way of doing this... ...

Maxmind geolocation apis: Apache vs PHP

I am looking to implement a very basic country limiting on my site based on the Maxmind geoip database (free version). Basically, I want to limit all users of the site to one country only. What I'm wondering is: is there any performance gain using the Apache API versus the PHP API? I want to be able to use the country code for more th...

What is the best way to store configuration variables in PHP?

I have considered the following $mysqlPass = 'password'; // doesn't seem right $config['mysql_pass'] = 'password'; // seems slightly better define('MYSQL_PASSWORD', 'password'); // seems dangerous having this data accessible by anything. but it can't be changed via this method class Config { const static MYSQL_PASSWORD = 'passwor...

PHP/MySQL simple connection won't work.

I'm hosting a website on Zymic (free host) that utilizes MySQL. I opened an account, and wrote the SIMPLEST function to connect to the DB. It looks like this: <?php $conn = mysql_connect("uuuq.com","paulasplace_sudo","mypassword"); if(!$con) { die("Could not connect: " . mysql_error()); } else { e...

What is a namespace and how is it implemented in PHP?

I've heard the latest PHP has support for namespaces. I know variables defined in the global scope have no namespace, so how does one make a variable in a different namespace? Is it just a way of categorising variables/functions? ...

How to force apache requests to use CGI WITHOUT the use of .htaccess

My school internal webserver is still running PHP v4.. (Not sure exactly). I went ahead and wrote all the labs and assignments on my local machine, which is running 5.2.5. Now, none of my code works on the school machine because the functionality simply is not there. I have access to a slew of compilers, and have downloaded the PHP v5...

Run PHP class from JavaScript

I need to fire a php class from a javascript function. code: <input type="button" name="Submit" value="Submit" class="opinionbox" onclick="verifyControl('<?=$control_no?>')"/> function verifyControl(rNo) { Cont_no=document.getElementById("ContNo").value; if(rNo==Cont_no) { frames['frame1'].print(); showPage('payment'); }...

Can Windows Authentication be used with PHP on IIS for ODBC connections?

Is it possible to use the users windows authentication (setting in iis) for database connections in PHP? This is possible in the .NET world through a technique called "impersonation". Does this also exist in the PHP/IIS world? EDIT: The Database I am using is MS SQL Server 2005. ...

Best Encryption algorithm (PHP) to authenticate users from other sites

I have two sites. The first site requires users to log in. An authentication token then will be passed to the second site when the users nagivate from the first to the second. So the users can't just grab the url of the second sites and login to it. What is the best encryption/ authentication algorithm that I can use for the this authe...

matching an IP to a CIDR mask in php5?

I'm looking for quick/simple/(maybe built in that i never noticed before), method for matching a given IP4 dotted quad IP to a CIDR notation mask. I have a bunch of IPs I need to see if they match a range of IPs. example: $ips = array('10.2.1.100', '10.2.1.101', '10.5.1.100', '1.2.3.4'); foreach($ips as $IP) { if( cidr_match($IP,...

PHP Embedded in Javascript

Hi friends, in my project I have the situation like this. <script language="JavaScript"> function fonsubmit() { alert('Out side PHP'); //Here the php code starts include("customerpage.php"); $cc="us"; $clang="en"; $cpath="us"; some coding goes here...... Php ends here } </script> But it shows Object e...