php

trying out new file upload method

so i've decided to upload the files onto the web server space rather than the mysql space but each time i try to upload anything i get the following error: Warning: move_uploaded_file() [function.move-uploaded-file]: Filename cannot be empty in /home/speedycm/public_html/manageclient.php on line 240 Warning: move_uploaded_file() [f...

PHP dereference array elements.

I have 2 arrays. $result = array(); $row = array(); Row's elements are all references and is constantly changing. For each iteration of $row I want to copy the values of row into an entry of $result and not the references. I have found a few solutions but they all seem rather awful. $result[] = unserialize(serialize($row)); $result[...

PHP to Powershell using shell_exec

If I run: $output = shell_exec('powershell "get-service "dhcp""'); I get perfect output of the service dhcp showing running but if I run: $output = shell_exec('powershell "get-user "testing""'); I get nothing. I don't see any difference in what Im doing here - and why get-service would work but get-user would not. If I run it...

How to determine if end of URL matches "/my-phrase"

I need to execute conditional code if the last part of the URL string is /my-phrase How can I parse the URL for a match after the last "/" character in the URL string? if(end of URL is "/my-phrase") { //dosomething;} else {//something else;} ...

Trying to create a mysql injection proof script

I'm just a beginner, What's wrong with my code, I'm trying to experiment on this so that the webpages I'm going to create will not be vulnerable to mysql injections. What's the correct way of doing this: <?php $host="localhost"; $username="root"; $password=""; $db_name="testing"; $tbl="hospital"; $connection=mysql_connect($host, $us...

Inserting Session variables into a form via PHP

I am trying to insert a Session Variable $_SESSION['MM_loginName'] into a table via a form. I know the Session Variable works on the new page by using: <?php echo "MM_loginName = {$_SESSION['MM_loginName']} <br>\n"; ?> I have read that this might work (if register globals is off): <input type="hidden" name="loginName" value="<?ph...

Zend framework: How to detect environment(dev/prod) in code

I use Zend_Mail component in my application for sending mails via SMTP protocol. And I want to persist my messages to files when I'm in development environment(accordingly to application.ini). How can I detect in my controller action whether it is development or production/staging environment? ...

Strip Down A String at Colon

Hi all, I have a textarea where a user copies and pastes the entire message: Time(UTC): 2010-02-27T21:58:20.74Z Filesize : 9549920 bytes IP Address: 192.168.1.100 IP Port: 59807 Using PHP, how can I automate this and parse this down to 4 separate variables, like so: <?php $time = 2010-02-27T21:58:20.74Z; $filesize = 9549920; $i...

PHP $_SESSION not working as expected

I have a PHP website I'm maintaining and I've confirmed that this worked at one point. We have a website utilizing a login system which stores a logged in user's information in a $_SESSION['user'] variable. The site used to log out the user when clicking /logout.php which essentially removed that portion of the session, then header() re...

Redirect users from other websites based on browser language

I want to do this: if (user from other website, like google, or input our website URL directly in the browser) { //redirect according to browser languge if (!preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) { wp_redirect("http://cn.gearor.com"); } } I don't know how to write the first if statement, I don...

how to echo an input type in php

Here's my code, what I want to do is to be able to have a back button in the script, so that the user will not be clicking on the back button on the web browser everytime he forgets to input something that is mandatory: But I get the parse error again,what should be the correct one? if(!isset($_POST['fname'])||trim($_POST['fname'])=...

Designing tag system that can tag multiple db tables

Hi, I am wanting to allow users to tag items so that they can search for them using tags. What is the best way of achieving this cleanly? So far the solution I have come up with only involves adding two extra tables to my current db system. <db Trackable product 1> int id; info etc </> <db Trackable product 2> int id; info etc </> //...

how to check if the inputted data is string in php

Possible Duplicate: Alphabetic equivalent of PHP is_numeric If you check if the data is a number, we use is_numeric: if(!isset($_POST['rnum'])||trim($_POST['rnum'])==""){echo "Error:Enter Room Number!"; echo '<input type="button" value="Back" onClick="history.go(-1);return true;">'; }else if(!is_numeric(trim($_POST['...

preg_match multiple help?

<?PHP $string = "[test]aaaaa[/[test][test]bbbb[/test][test]cccc[/test][test]ddd[/test]"; echo $string . "<br>"; preg_match("/\[test\].*?(\[\/test\])/i", $string, $m); print_r($m); ?> how to get value aaaaa and bbbb in multiple from capture [test] and [/test] ? ...

Using session variable as search parameter for a table

I have been using SESSION Variables to enter data with loginName as way to retrieve only records that contain that Users loginName. How do I create a form that can search using this parameter and bring up all the records that the user created. This is what I use to input the SESSION variable into the record. <input type="hidden" name...

Using TCPDF and FPDI with cake php

Hi Guys, I have go TCPDF setup in my cake php install and am now trying to also use FPDI with it as i need to add a PDF to the start of the PDF that is being generated. WHen trying to do this i am using 3 classes XTCPDF which holds my header data FPDI - FPDI class TCPDF - TCPDF class and it is setup as so: XTCPDF extends FPDI FPDI...

I need to get xml with php. How would I go about that?

What is the best way? ...

Google Groups alternative

Hello, I'd like to be able to have Google groups functionality on my site. Meaning having the ability for people to email each other, with the emails posting to my site, in a threaded manner. Though I'm ideally looking for something free, if there's software out there that accomplishes this for a price, I'm also interested in learning ...

xml editing backend

I would like to have an xml editing interface for a site's backend. There are many php based CMSes of varying sizes (my favorite being modx), but for some projects it is just overkill. The point of this xml management system would be that the user would have a graphical interface for xml file generation, from the browser. some additi...

Is there a way to identify forms if using the button element to submit?

I've started using the button element to submit my forms <button type="submit">Send</button> I know if I used an input element like so, I could easily determine in PHP which form was submitted (by reading the value of $_POST['form'] in the example below). <input type="submit" value="Send" name="form" value="contact" /> Is there a ...