php

Need help parsing some data in PHP

I need to be able to parse this sort of data in PHP: Acct: 1 email : [email protected] status : online -------------------------------------------------- Acct: 2 email : [email protected] status : banned -------------------------------------------------- Acct: 3 signedupname : SomeUsername ...

Need to setup a comprehensive e-commerce page for the first time--Magento?

Hey guys, I'm a designer (starting to learn PHP/MySQL) and am need in an eCommerce platform (it does not have to be free) that will allow me to create a comprehensive eCommerce site--countdown promotions, related products, user reviews, payment/shipping processing, etc. Basically just populating it with products, and styling the pages. ...

Is using superglobals directly good or bad in PHP?

So, I don't come from a huge PHP background—and I was wondering if in well formed code, one should use the 'superglobals' directly, e.g. in the middle of some function say $_SESSION['x'] = 'y'; or if, like I'd normally do with variables, it's better to send them as arguments that can be used from there, e.g: class Doer { private $se...

Doctrine: Set field value to SQL expression

I need to set value in mapped record to some arbitrary sql expression, so on obj.save() it would be used directly, w/out escaping/quoting. Something like this: obj.location = "Point($x, $y)"; obj.save(); Which should result in query like UPDATE ... SET location = Point(..., ...) WHERE ...; However I cannot find anything like this i...

Assigning Gettext String to Class Member

I'm making a site that will be translated into x languages. All strings must be localized. There are occasions when I need to display a language name, country name or other information that has been retrieved from a database. The data being dealt with in this way will seldom be changed - as above I'm talking about language names, count...

Invalid URL message when uploading an image file using urllib2

Hello, I am trying to upload an image file to piczasso.com from python. My code is as follows: import urllib,urllib2 url='http://piczasso.com/api_handler.php' values = { 'data':open('./imagefile.jpg'), 'tags':'', 'size':'None' } data = urllib.urlencode(values) req = urllib2.Request(url,data) try: respons...

Using cURL for Amazon Associates reports... possible?

I've got a couple of affiliate sites and would like to bring together the earnings reports from several Amazon sites into one place, for easier viewing and analysis. I get the impression that cURL can be used to get external webpage content, which I could then scrape to obtain the necessary info. However, I've hit a wall in trying to lo...

reliably detecting line breaks in php

I'm going to build a wee batch search field where someone can enter/paste in a bunch of keywords separated by a linebreak, they might be copied in from excel, word or where-ever. So I plan to use php to explode() that input and loop through it for an SQL search. Do I need to do anything special to reliably detect the line breaks - my u...

PHP get_called_class() alternative

I've got an Abstract PHP superclass, which contains code that needs to know which subclass its running under. class Foo { static function _get_class_name() { return get_called_class(); //works in PHP 5.3.*, but not in PHP 5.2.* } static function other_code() { //needs to know echo self::_get_...

Date format with all capital letters

Hello, The PHP code below returns dates in this format: July 27, 2010 7:36 pm How could I make it return dates with capital letters? Here's what I want; JULY 27, 2010 7:36 PM Thanks in advance, John The PHP code: format('F j, Y &\nb\sp &\nb\sp g:i a') ...

PHP link problem.

I'm trying to display a link orange when clicked but for some reason I can get it to work when using PHP can some one help me correct this problem? Here is the PHP code. function category_tree( $parent = 0, $parent_url = '' ){ $page_url = current_page_url();//grabs url address echo "<ol>"; $mysqli = mysqli_connect("localho...

preg_match: ensure the start and the end contains something

Hi, I want to have the regular expression that makes sure the beginning of the string contains 'http://' and '/' and the end. This is a longer version I came up with, if(!preg_match("/(^http:\/\//", $site_http)) { $error = true; echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm ...

jQuery + PHP : Deleting rows from a table from multiple ID's

Hey guys. I am somewhat new to jQuery and javascript in general. What I have is a CMS that I am upgrading. In doing so, I have started an option to delete multiple categories at once via checkboxes, which is processed via jquery/ajax. In deleting the records individually, I could remove the row of the table once deleted, but now with ...

INSERT - PHP & SQL Server

I don't know what is going on, but it just doesn't want to work. I keep getting this error when I submit my form: Array ( [0] => Array ( [0] => 22001 [SQLSTATE] => 22001 [1] => 8152 [code] => 8152 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]String or binary data would be truncated. [message] => [Microsoft][SQL Serve...

screenshot in php

I am using google visualization api for my php-based website. I am planning to use tcpdf to give a pdf version of the same images that i am generating using Google Visualization API. is there any way to save these visualizations on my server so that i use them directly in the tcpdf? If not then can i automatically take screenshots of t...

How do I create an associate array in jquery and send it via ajax to get parsed with php?

How would I make an associative array (or some comparable alternative) in jQuery AND send that array via ajax to a php page so that I can use php to handle it? Something like this... // jQuery if($something == true) { data[alt] = $(this).attr('alt'); data[src] = $(this).attr('src'); else if ($something == "something else") { ...

implimenting set theory operations in php

Does anyone have any examples or know of any resources that show how to implement set theory operations in pure php? ...

assignment operator (=) within a function's parameter list?

I'm using the following code from PHPBuilder.com to handle user privileges on my site: /** * Correct the variables stored in array. * @param integer $mask Integer of the bit * @return array */ function bitMask($mask = 0) { if(!is_numeric($mask)) { return array(); } $return = array(); while ($mask > 0...

Why is preg_replace giving this output?

I just can't figure this out, for some reason this: $string = "#mainparent { position: relative; top: 100px; left: 100px; width:4994px; }"; $elementwidth = "88"; $re1='(.*?)'; # Non-greedy match on filler $re2='(mainparent)'; # Word 1 $re3='(.*)'; # Non-greedy match on filler $re4='(width:)'; $re5='(.*)'; # Word 2 $re6=...

nl2br not working for me, please help

Hi all, I can't get nl2br function to work after fetching data from my DB... $result = mysql_query("SELECT comments..etc.etc.."); while ($row = mysql_fetch_array($result)) { echo nl2br($row["comments"]); } In DB row comments: \r\nThanks,\r\n OUTPUT: Same as in DB: \r\nThanks,\r\n If I simply test this out like so it works f...