php

Seamlessly direct multiple domains to a single set of PHP files?

I need to direct multiple domains to a single set of (PHP) files. So I point a domain at my server, which then goes to a single index.php file. This index.php file then detects the domain accessing it and returns the appropriate content. I do not want to add domains or set-up sites manually though as this is for a content management serv...

How to implement language packs in PHP

I created 3 language packs for my site: English, Spanish and French. I am just having trouble implementing them based on user selection. I have the following drop down menu: <select onchange='document.location.href=this.options[this.selectedIndex].value;'> <option>Select</option> <option value="?lang=eng">US English</option> <opt...

Which is faster? Main script or variable script

Which of these would provide the most functionality? Defining the templates within the variable: elseif($global[action] == "edit_template") { $template_content = template_get($_GET['template']); $template_content = str_replace('\"', '"', $template_content); $template_content = str_replace('</textarea>', '&lt;/textarea&gt;',...

PHP class variable set/get problem

I've attempted to write a PHP class that gets the uptime of my Linux machine. It will get the uptime correctly, but I have an if statement that determines whether or not the load average is "high" or not and set a warning code, and it doesn't seem to be working (it stays at 0). I've included all of the code here from the class (50 or so...

How do you create a PHP eval loop?

The code I'm using is: while($template = array_loop($templates)) { eval("\$template_list = \"$template_list\";"); echo $template_list; } It appears to detect how many templates there are successfully, but it just shows the same name for them all: Name: LayoutName: LayoutName: LayoutName: LayoutName: LayoutName: LayoutName: La...

search by category with php mysql

hello im using this code to do search <form action="arama.php" method="get"> <input type="text" name="lol"> <select name='kategori'> <option value="tum">Tum kategoriler</option> <? while ($kat = mysql_fetch_array($kategori_isim)) { echo " <option value=".$kat[kategori_isim].">".$kat[kategori_isim]."</option>"; } ?> </select> <inpu...

Why can't I overload constructors in PHP?

I know it can't be done, well I hope it can't or my Google skills have failed me. But my annoyance is beyond that now, I have abandoned all hope of ever being able to overload my constructors in PHP, so what I'd really like to know is why. Is there even a reason for it? Does it create inherently bad code? Is it widely accepted language ...

Form validation with Ajax and PHP - return a variable from PHP to use in javascript function

I'm using Ajax via jQuery for the first time ever. I have an html input and when a user clicks it and types something and then the focus blurs, i'm using jquery to call a php script to validate the user's input. I'm trying to figure out how to take the variable in PHP and compare it in jQuery. Please give me any advise Right now when ...

remove element from array based on its value?

i've got a regular array with keys and values. is there a simple way to remove the array element based on its value or do i have to foreach-loop it through and check every value to remove it? ...

REST API in PHP output to JSON file extension

So I want to write a REST API in PHP for JSON for consumption on the iPhone, but also a lot of websites and devices. I have the below code, when accessed via a GET statement, returns a file like: 1mdi2o3.part How do I return something like: users.json $db->setQuery( "SELECT * FROM users"); $db->query() or die($queryError); $numRows ...

How to insert form data into MySQL database table

So I have this registration script: The HTML: <form action="register.php" method="POST"> <label>Username:</label> <input type="text" name="username" /><br /> <label>Password:</label> <input type="text" name="password" /><br /> <label>Gender:</label> <select name="gender"> <optgroup label="genderset"> <opt...

Parsing the output of Linux command 'who' in PHP

I've tried parsing a list of users currently connected via SSH to a server, but the results are very irregular, so I was forced to simply do: $users = shell_exec('who'); echo "<pre>$users</pre>"; Is there a better way to parse the output of who in the command line before I let PHP mess around with it? I want it in an array which conta...

JavaScript injected form field does not appear in POST data

hey guys. I have a form that generates new input fields via JavaScript on click. the inputs are successfully added to the FORM with the desired naming convention. <input type="text" name="util_name0" id="util_name0" value="" /><br/> <input type="button" onClick="newUtil(this)" value="Add New" /> newUtil() adds: <input type="text" nam...

data mapper vs active record

What are the advantages and disadvantages of both active record and data mapper? Please be PHP-specific, where the language matters. Personal experiences are welcome! Ideally with both. ...

PHP: Wiki style before/after edit comparisons of text

Say I had 2 paragraphs of text to compare.. 1) "Text text text text text text text text text text text text text text text" 2) "Text text text text text text text text NEW TEXT text text text text text text text" How would I go about finding out what the different parts are from the first paragraph to the next (like what you see in w...

PHP super fast xml updates required

Hi there, i run a system which needs to update various xml files from data stored in a db. The script runs via a server side php file which is monitored by a daemon so that it executes, finishes to free resources, then is restarted. I have some benchmarking within the script, and when i have to update 100 xml files, its taking about 15...

How can I learn to use Oracle DB with PHP?

I would like to learn to use Oracle some, just for the sake of learning it. Is there a way to do this without spending a lot of money? I looked on the oracle site and the cheapest thing I saw was this... Oracle Database Personal Edition Oracle Database Personal Edition is designed to provide software developers a cost effective, yet...

How can I implement OCR on a website using PHP?

Are there any free OCR libraries that work with PHP? Perhaps there is a different way to do OCR on a website. If so please share. EDIT: Python is also acceptable. EDIT2: I'm working with a Linux server, ideally. ...

Dynamically picking variable from a class

I'm trying to get data from a class in php5, where the data in the class is private and the calling function is requesting a piece of data from the class. I want to be able to gain that specific piece of data from the private variables without using a case statement. I want to do something to the effect of: public function get_data($f...

PHP: Split string into array, like explode with no delimiter...

I have a string such as: "0123456789" and need to split EACH character into an array. I for the hell of it tried: explode('', '123545789'); But it gave me the obvious: Warning: No delimiter defined in explode) .. How would I come across this? I can't see any method off hand, especially just a function ...