php

java writeInt from php,

hey all i am trying to make a data output stream in php to write back primitive data types to a java application i created a class that write the data to an array (write it same as java do , copy from java code) and finally i am writing back the array to the client. feels like its not working well for example the writeInt metho...

Why isn't this simple function working?

I didn't want to keep repeating the same select query, so I wrote this function. But it doesn't work: function select($what, $table) { $query = mysql_query("SELECT $what FROM $table"); } select(*, products); ...

How do I tell how much memory / resources is my php script using up?

Hi guys I'm debugging my application here and basically in a nutshell - the application is dying out on my online server or maybe its my server dying out. But I have checked this application three different servers and all exhibited similar results, the application would run for a while but all of a sudden once I'd be opening more and mo...

How are exceptions handled in PHP?

Hello, Can anybody tell me how are exceptions handled in PHP? I have this code try{ $this->b->methodthatraisesexception(); } catch(Exception $ex){ echo "Hi Hi hi, you tried to deleted a non existing file"; } When i try to run this code instead of seeing the echo message, i see some kind of weird PHP error occured message. Btw, t...

PHP dump $_REQUEST to file

I want to dump request variables to a file for debugging. How's this possible? ...

give the job to MySQL or to PHP?

I have some several codes in PHP to do jobs that MySQL could do. such as sorting, merging each data from different MySQL tables, etc... Lately, I found out that I can do all these stuffs with one MySQL query. I am wondering is it better to give the MySQL capable jobs to MySQL or to PHP. efficiencies, speed, etc.. Thank You, ...

How do I add content to an existing XML file??

I do have an xml generator written in PHP. sample is given below but few lines only due to space issues. $output = '<?xml version="1.0" encoding="UTF-8"?>'."\n"; $output .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:ta...

How does this giant regex work?

I recently found the code below in one of my directories, in a file called doc.php. The file functions or links to a file manager. It's quite nicely done. Basically, it lists all the files in the current directory, and it lets you change directories. It had access to all my files (add, rename, info, delete...). I don't remember installi...

Generate a space with HTML that a printer will ignore

I have some code that generates bills for multiple customers on one web page. I use the div element style="page-break-after:always" so the user can print every customers bill at once, and the bills for unique customers will all be printed on a separate sheet of paper. My issue is that I want the bills to be a little more readable on th...

Should Nginx Be Combined With Language Supporting Asynchronous Programming Model?

I found there are a lot of articles comparing Nginx and Apache in Internet. However, all these comparisons are based on stress test to web server running PHP code. I suppose this is mainly due to Apache is generally deployed with PHP as LAMP architecture. In my understanding, Nginx is created to solve C10K problem with event-based arc...

jQuery post a serialized form then inserting into mysql via php?

Hello, I'm trying to post a serialized form to a sumbit.php file, in turn, will then insert into a MySQL database; however, the last input which is hidden, is not getting inserted into the database, though the rest are. Here's some snippet examples of what I've got thus far which is not working: HTML <form method="post" ...

PHP 5.3 Namespaces and use

i am wondering why my namespaces are not resolved correctly ... i have use \Doctrine\ORM; ... } catch (NoResultException $e) { // shld resolve to \Doctrine\ORM\NoResultException but fails ... } catch () { // code always ends up here if NoResultException is thrown // unless i fully qualify the class as\Doctrine\ORM\NoResultExc...

Include statement taking up 1.5 MB of memory?

Hi guys I'm trying to optimize my application here and have started to benchmark snippets of code as to how much memory they are taking up. I just discovered that a single include statement is taking up to 1.5MB of memory. I'm using memory_get_usage() to check for memory used before adn after a snippet of code. The file included include...

Can anyone tell me any SMTP server i can use to send an email from my php page?

i also want know how to authenticate and use Google SMTP server. ...

Retrieve Data Step by Step after a certain delay using ajax and jquery in php

I am a beginner at Jquery. What i want is to display the data using AJAX in a step by step manner. So let say if in my database there is a table "DATA" with a field name "info" having multiple rows as a data info 1 2 3 4 5 Now i want to display all the five rows but after a certain delay of time let say after a second. So i want to ...

array_shift not removing the first element of the array

I have the following code echo '<pre>'; print_r($this->region_id); echo '</pre>'; if(end($this->region_id) != 0){ if($this->region_id[0] == 0){ array_shift($this->region_id); } } echo '<pre>'; print_r($this->region_id); echo '</pre>'; Somehow it's not removing the first ...

find and edit comment element of html with php

I need to edit the inside of the following comment tag so that I can change the location of the css file. This needs to be done through PHP. I have tried using the following code but I get invalid expression errors. Comment Section: <!--[if IE 6]><link rel="stylesheet" type="text/css" href="/Css/IE6.css" media="screen" /><![endif]--> ...

html_entity_decode() isn't working properly?

EDIT: I solved it seconds after posting the question (sorry!) but can't accept an answer yet. Hi folks, Just a quick one. I have a PHP/CodeIgniter site and the user can edit their profile. I'm using CI's XSS Filtering and Active Record-based Models, so the data is escaped automatically. It naturally displays fine on the profile page v...

save php variables permanently without database

In the admin area of my site there is a form which is for the hostname, username and password for the mysql database that the site uses. Currently these values are hardcoded into a php class. But who can I link it so the form can edit the variables in the php class (and keep the results on the server, in other words the variables are har...

Passing models in array format to views in YII

How can I pass the model in array format. I want to pass models in this format from controller to view:- Users[user_contact]=Contact Users[user_contact][contat_city]=City Users[user_contact][contact_state]=state This is what I am doing public function actionCreate() { $user = new Users; $presContact = new Contacts; $presCi...