php

PHP: Need help removing line break from code

I am trying to get names from a .txt file. I am using file('filename.txt') but if i use a php for loop to try and trim the names, it comes out on multiple lines: This is the actual line that prints the javascript (NOTE: I am going to be putting these names into a select box, if you can fix the problem at hand the rest of the code should...

AJAX Counter and Update Panel help needed !!!

I am making a clone of quibids.com in asp.net. This site is in PHP. Can anyone check it and tell me which technology / language they are using behind those so many running counters at the same time ? Is that server side counter or client side counter ? I have tried ajax counter and ajax update panel in asp.net but it is taking so much ti...

What would be the PHP equivalent of this Perl regex?

What would be the PHP equivalent of this Perl regex? if (/^([a-z0-9-]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/ and $1 ne "global" and $1 ne "") { print " <tr>\n"; print " <td>$1</td>\n"; print " <td>$2</td>\n"; print " <td>$3</td>\n"; print " <td>$4</td>\n"; print " <td>$5</td>...

How do I get PHP variables from this MySQL query?

I am working on an Asset Database problem using PHP / MySQL. In this script I would like to search my assets by an asset id and have it return all related fields. First I query the database asset table and find the asset's type. Then depending on the type I run 1 of 3 queries. <?php //make database connect mysql_connect("localhost...

Magento - Add bundled products from PHP with Magento API

Is it possible to add bundled products with Magento API? If not, is there any other way to add a bundled product? ...

Maintaining white space in html select tag

Hi, I have a list of strings that I would like to display in a HTML select object. The strings look something like : id - name - description I would like the fields to align however. In PHP I'm using sprintf ("%4s%10s%20s", $id, $name, $description); which works fine. The problem is the multiple spaces is compacted to 1 space in t...

PHP Arrays: Loop trough array with a lot of conditional statements. Help / Best practices

Hi, I have a problem I don't know how to get it to work the best way. I need to loop trough an array like the one below. I need to check if the [country] index is equal to a Spanish speaking country (lot of countries I predefine) and then get those [title] indexes of the correspondent country, check for duplicates and create new more co...

PHP created directory with NO permissions ...?

Just had something really weird happen, and I'm not sure why. Our site crashed because PHP couldn't write a cache file to a directory which is created automatically by the script. When I investigated, I saw that the directory had NO permissions: no read or write for owner, group, or public. This script creates directories hundreds of t...

Variable within variable possible?

I am trying to create a loop statement for some of my code and am wondering how I can put a variable within another variable. For example: <?php $j=1; while ($j <= 9): { $f$jfname = $_SESSION['F$jFirstName']; $f$jmi = $_SESSION['F$jMI']; $f$jlname = $_SESSION['F$jLastName']; } $j++; endwhile; ?> Where the goal is to have the j va...

Get class constant names in php?

I have a php class with some class constants that indicate the status of an instance. When I'm using the class, after I run some methods on it, I do some checks to make sure that the status is what I expect it to be. For instance, after calling some methods, I expect the status to be MEANINGFUL_STATUS_NAME. $objInstance->method1();...

PHP's PDO ODBC connection is failing to connect to Intersystems Caché DB

I have the developer version of the Caché DB running locally. When I try to use PDO ODBC to connect to it I just get errors: Connection failed: SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified I've used several DSN statements such as: #$conn = "odbc:host=127.0.0...

PHP SASL(PECL) sasl_server_init(app) works with CLI but not with ApacheModule

I have written a simple auth script so that Webusers can type in their username and password and my PHP script verifies them by SASL. The SASL Library is initialized by php function sasl_server_init("phpfoo"). So phpfoo.conf in /etc/sasl2/ is used. phpfoo.conf: pwcheck_method: saslauthd mech_list: PLAIN LOGIN log_level: 9 So ...

Installing ImageMagick extension with php/windows

Running PHP Version 5.2.5 on Windows Server 2003 with IIS. Have virtually an identical server where we were able to install ImageMagick with no issues. It's running exactly the same version of php. Used the following steps to install, but it just won't seem to work on this server. ImageMagick itself is installed but php won't load the e...

How to call a script that expects $_POST from inside a function

My script.php accepts $_POST input and echos a string. $theinput = $_POST['theinput']; $output = //some processing; echo $output; I need the same code in another function in a different file second.php and don't want to repeat the code. But the first script script.php expects input as $_POST. My input in the function is not $_POST ju...

How can I allow only privledged users to download a pdf with php?

Lets say I have some pdf files stored on my server and I only want to allow a person who's paid have access to download a particular pdf. So for an example, let's say I have a bunch of e-books. The only way a user would be able to download e-book A is if his account contains the right credentials for that particular book. What's the b...

Detecting a response from an api

I am currently working with an API, currently the sequence of events is I send an XML request to the api provider and it responds with a response in the format of some XML also, I was hoping there would be a way for me to detect when this reponse is sent back so I can show the user a loading message while the response is sent. Ideally I ...

Facebook API - delete status

In PHP, I'm using curl to send a delete to the fb graph api - and yet I'm getting the following error; {"error":{"type":"GraphMethodException","message":"Unsupported delete request."}} The code I'm using is; $ch = curl_init("https://graph.facebook.com/" . $status_id . ""); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CU...

Spotlight search with PHP

Hi. I want to add a spotlight search functionality - search results being displayed with rich contents like thumbnail etc in a drop down menu changing on each keyup event - just like the apple.com search - to a site, having data in MySQL InnoDB tables. So basically that is displaying search results based on the part of the query that has...

php validation function for name that allow UTF-8 characters plus - (minus) and space

Hello everybody, Please help me with a function that validate an input string to allow: 1) UTF-8 characters (ex: şţăîâ) ; 2) space ; 3) minus symbol(-) String cannot start or end with space or minus. Thanks! ...

Web Form Security

I set a cookie in the headers with an md5 hashed keyword. Then in my code, it checks for the exact matching cookie before displaying a form. Is this pretty much pointless? The form submits to an external site, so I am trying to secure the form without using captcha.. ...