php

Detect windows domain username in PHP

Is there anyway, in PHP, to detect someone's username? I want to track the users that visit and download particular files on our internal site? ...

PHP: How do I loop through every XML file in a directory?

Hi! I'm building a simple application. It's a user interface to an online order system. Basically, the system is going to work like this: Other companies upload their purchase orders to our FTP server. These orders are simple XML files (containing things like customer data, address information, ordered products and the quantities…) I...

Get records from a specific month using SQLite

How would I write a SQLite query to select all records from a specific month? My dates are stored as Unix timestamps. PHP code is allowed in your solution if it's required. SQLite2-compatible queries only, please. :) ...

SQL & PHP - Which is faster mysql_num_rows() or 'select count()'?

I'm just wondering which method is the most effective if I'm literally just wanting to get the number of rows in a table. $res = mysql_query("SELECT count(*) as `number` FROM `table1`"); $count = mysql_fetch_result($res,0,'number'); or $res = mysql_query("SELECT `ID` FROM `table1`"); $count = mysql_num_rows($res); Anyone done any d...

Programming language detection in PHP

I need to detect which programming language is used in a code snippet, there is any library to do this? I already read this http://stackoverflow.com/questions/475033/detecting-programming-language-from-a-snippe, but I rather use a tested and working library. ...

PHP: Array access short-hand?

In Javascript, after executing a function I can immediately get the an element of the array returned by the function, like so: myFunc("birds")[0] //gets element zero returned from "myFunc()" This is much easier and faster than doing this: $myArray = myFunc("birds"); echo $myArray[0]; Does PHP have a similar shorthand to javascript?...

how to make a php script that read an email from the server?

hello is there any way that when i user send an email to [email protected] the php script reads the email's information and replay to the user automatically ? EDIT :: is there any method that when someone send me an email to [email protected] a script will be called that's better than using cron job every 5 seconds Cheer ...

Intercept page request behind firewall return altered content with php and apache

I'm providing free wifi service and need an ad to be added to all page requests. Currently I have a router forwarding all http requests to an apache server, which redirects all requests to an index.php page. The index.php page reads the request, fetches the content from the appropriate site, and edits the content to include the ad. The...

How can I get a phone number customers can sms to that posts the information to my website?

i need an sms service that can gives me a phone number and then my customers can send me sms to that number. then posts the sms information to my website like http://xx.com/newsms.php?body=hey Thanks ...

How to replace all instances of a particular value in a mysql database with another?

I'm looking for a MySQL equivalent of what str_replace is for PHP. I want to replace all instances of one word with another, I want to run a query that will replace all "apples" with "oranges". The reason why: UPDATE fruits SET name='oranges' WHERE name='apples'; isn't going to work for my situation, is because I often times have mult...

php boolean help

Hello, I seem to have a small problem, in the code below $a_trip is always true, even if $trip!= $admin_trip. Any idea why? if($trip == $admin_trip) $a_trip = true; if($a_trip == true) $trip = ("~::##Admin##::~"); ...

how to fetch a url with javascript/jquery?

i need to fetch a url with javascript/jquery and not php. i've read that you could do that if you got a php proxy, but that means that it is still going through php. cause then it's still the ip of the server that is fetching it. could one fetch the url entirely with only front-end, and thus fetch it with the client's ip? ...

Which PHP version is required for str_split?

I relogin to my server in dreamhost and test some scripts.And I found I couldn't use str_split. Message of Undefined function was given.I checked the version in the server and its PHP Version is 5.2.12.And I just wonder which version is required?Thanks. Testcode: <?php $arr = str_split("lsdjflsdjflsdjflsdjfl"); print_r($arr); ?> Mes...

How can I destroy sessions if user closes the browser window or navigates away from page in php?

I have some sessions that are saved. I want to destroy all the sessions if the user closes the browser window or a single tab or navigates away from the page. Is there any way I can do this? ...

PDF form submission

I have a PDF form (made in Acrobat) that has button to submit via HTTP. What I want to do it have a PHP script that will take the PDF form and e-mail it to me via attachment. What I don't want: --PDF Submit via e-mail button. This requires webmail users to save the pdf and attach it, and is just too confusing for most users. I want ...

How to search a MySQL database for a specific string

I am trying to set up a search feature on my site that will only return exact matches to keyword entered by the user. So if the user searches "dog" I don't want an article titled "Doggy Style" to appear in the search results (just an example I don't really have an article by that name). This of course does exactly that: SELECT * FROM ar...

CMS Preventing Bad HTML Insertion by Client?

I'm building a small CMS in PHP for a client and something I've noticed that comes up fairly often is a client will enter a bit of HTML in a field without closing his/her tag. I'm wondering if there is some parsing technique to prevent bad HTML from rendering my whole output page in italics because the user forgot to add a closing </i> ...

speed up a sql query to mysql?

in my mysql database i've got the geonames database, containing all countries, states and cities. i am using this to create a cascading menu so the user could select where he is from: country -> state -> county -> city. but the main problem is that the query will search through all the 7 millions rows in that table each time i want to ...

Count # of links programmatically

Is there a way I can programmatically count the number of links for a website? Does google provide an api that can I can programmatically query? ...

How to convert a child instance to parent class and the reverse in PHP?

$child_instance = (childClass)$parent_instance; $parent_instance = (parentClass)$child_instance; Or is it possible? ...