php

Website Link Injection

I have a website that is fairly static. It has some forms on it to send in contact information, mailing list submissions, etc. Perhaps hours/days after an upload to the site I found that the main index page had new code in it that I had not placed there that contained a hidden bunch of links in a invisible div. I have the following code...

PHP: Loop or no loop?

In this situation, is it better to use a loop or not? echo "0"; echo "1"; echo "2"; echo "3"; echo "4"; echo "5"; echo "6"; echo "7"; echo "8"; echo "9"; echo "10"; echo "11"; echo "12"; echo "13"; or $number = 0; while ($number != 13) { echo $number; $number = $number + 1; } ...

PHP case-insensitive in_array function

Is it possible to do case-insensitive comparison when using the in_array function? So with a source array like this: $a= array( 'one', 'two', 'three', 'four' ); The following lookups would all return true: in_array('one', $a); in_array('two', $a); in_array('ONE', $a); in_array('fOUr', $a); What function or set of functions wou...

Get rid of ASCII characters in the output of HTML parsed by DOMdocument

Let's say I have this code, adapted from Adam Backstrom's answer to a previous question: $term = 'example'; // word I need to replace $replacement = '<strong>example</strong>'; // this will replace the $term $d = new DOMDocument; @$d->loadHTML($body); // specifically, drupal's $node->content['body']['#value'] in hook_nodeapi when $op='...

What's the best way to manipulate the way entries in a data base are displayed on my web page?

I have a client I am building a small CMS for. One of the functions is that he would like to be able to pick the order in which images display on a page. In my mySql Database I have a table called image_info with the fields: index (auto incremented) img_url img_link I was thinking of adding an additional field called img_order whic...

How to fix this simple MySQL display order issue

I'm very new to MySQL so I need some help please, I have a table called "posts", this table has the following columns: id - this is auto increment and primary key title content I have a PHP page where I want to display all the posts from the database table. I want the title to show first and then the post content followed by the title...

Avoiding specific PHP Fatal error: Uncaught exception to allow script to continue running

Hi all, I would like to make it so that my scripts can continue to run even if there's a CERTAIN fatal error. Right now I can get this fatal error: PHP Fatal error: Uncaught exception 'MongoConnectionException' with message blah blah. How do we catch this specific error, log it, but allow the script to continue to run? Anyone has idea...

Multi column dynamic PHP list.

So what I'm trying to do is select all the distinct months from my database and then print them in a list. That, I can accomplish. The problem lies in the fact that I need my list to be two column. The way that I achieve this with CSS is by using 2 different div's "left" and "right" which are floated next to each other. This poses a prob...

Needed: User drags 4 favorite images out of group of possibles into 1st Place Box, 2nd Place Box, etc..

Oh! Too many dragNdrops out there! Prefer the sleekest for my needs. DragNdrop images: I want my visitors to select exactly 4 favorites from a "corral" of, say, 8 jpgs. Dragndrop each from the bottom "corral" up and into 1st Place thru 4th Place Boxes... Unused images remain below, unmoved in "corral", blank space-holder if picture is ...

Will multiple "foreach" queries in PHP slow down the page load?

When querying data via PHP, will it significantly slow down the page loading time if I can the items separately? For example, pulling in three items at a time: <?php foreach ($example->get_items(0,3) as $item): ?> Versus call each of the separately: <?php foreach ($example->get_items(0,1) as $item): ?> <?php foreach ($example->get_i...

Adding Search Capabilities to my website

Instead of writing a PHP script from scratch, I wanted to know if there are any free scripts, plugins, or APIs out there that allow me to add a search box to my website to search only content on my site. Google's free version is ad-supported, and I am looking for a clean, simple, and non ad-supported solution. Any ideas? ...

how to chop of a text in a certain length with php?

i wanna get some field values from database and present them on html. but some of them are longer than the div width so i wanted to chop if of and add 3 dots after them if they are longer than lets say 30 characthers. windows vs mac os x-> windows vs m... threads about windows vista -> threads about win... how can i do that? ...

Method for key-value pair similar to explode in php?

Is there an already existing function in PHP for creating an associative array from a delimited string? If not, what would be the most effective means of doing so? I am looking at PayPal's new NVP API, where requests and responses have the following format: method=blah&name=joe&id=joeuser&age=33&stuff=junk I can use explode() to get ...

Any advice on parsing an OPML file with PHP so I can import the addresses into a mySql database?

I want to be able to have the user select an OPML file that contains a large number of bookmarks, then loop through each one and toss it in a mysql database. Any direction would be much appreciated. ...

help...! same page file upload to mysql...

hey so i decided against using uploadify as i could not get any help on it. i've been now trying to implement a simpler solution. but unfortunately i cannot seem to process the upload code on a single page without receiving the following error: Warning: fopen() [function.fopen]: Filename cannot be empty in C:\xampp\htdocs\speedy...

I have learned the basics of PHP. So what's next?

I heard of frameworks like Ruby and cakePHP (correct me if I'm wrong). So should I proceed to learn them? If so, which one is the more preferred among PHP developers? ...

How to limit the display of content from a database?

I am using the following code to display the title and body content of articles from a database. How can I make only the first 200 characters from the article's body appear as opposed to all the characters? <?php $select = mysql_query("SELECT * FROM articles ORDER BY id DESC"); while ($result = mysql_fetch_assoc($select...

how to insert am pm in a time datatype filed in mysql

i want to save a library all 7 days open time and close time please suggest how to do it... right now i m doing like this on database i crate a db table_lib_hours -----FIELD-----x--TYPE---------- |day_id |INT | |day_name |varchar(100) | |day_open_time |TIME | |day_close_time|TIME | |last_update ...

Regex to match all characters except letters and numbers

I want to clean the filenames of all uploaded files. I want to remove all characters except periods, letters and numbers. I'm not good with regex so I thought I would ask here. Can someone point me to a helpful site or show me how to put this together? I'm using PHP. ...

Working example of PHP's __dorequest method for SOAP?

I am trying to use the MS Exchange 2007 Web Services from PHP and my first snag (of course) is successfully authenticating to the wsdl file when creating the SoapClient object. I am able to fetch the WSDL file via curl simply by setting HTTPAUTH and USERPWD: $exch = curl_init($exch_url); curl_setopt($exch, CURLOPT_RETURNTRANSFER,...