php5

How to save URL's to a MYSQL database from an array

What is the best way to save a URL or symbols into a MYSQL database. I'v seen this being used "{$htmlOutputArray[1]}" and then else where this "$htmlOutputArray[1]" and some other places do what i'v done below... but which is the best? So far I have: (example code) $html = "034251\nhttp://stackoverflow.com/questions/ask" $htmlOutputAr...

get_file_contents fails with 400 response code

I have the strangest issue ever. I'm trying to get results of CGI script running on the same server with get_file_contents and it works everywhere except my local machine under Ubuntu. It works when I ask it to get url from different server (same script running on production), it works deployed on different server, I'm absolutely sure I...

Weird PHP error: 'Can't use function return value in write context'

I'm getting this error and I can't make head or tail of it. The exact error message is: Fatal error: Can't use function return value in write context in /home/curricle/public_html/descarga/index.php on line 48 Line 48 is: if (isset($_POST('sms_code') == TRUE ) { Anybody knows what's going on??? PS Here's the full functio...

Excessive use of $this as object param in PHP5, How to avoid?

Hey all. I've been working in PHP5 for a couple of years now and have developed a lightweight MVC framework that I use to speed up site development. Works great, automated formbuilder, autoSQL module, etc. One bad habit that I have developed, however, is relying on $this as an easy object param. I have yet to figure out how to truly en...

Preventing SQL injection: is mysql_real_escape_string() really all I need?

Possible Duplicate: Best way to stop SQL Injection in PHP It seems far too good to be true to me that this simple function does all I need. Yet most of my google searches lead to results that basically say "just use this function and all will be well!". I've seen a couple that briefly, or at too high a level for my own beginner...

Getting values from associative array

I have the following main array called $m Array ( [0] => Array ( [home] => Home ) [1] => Array ( [contact_us] => Contact Us ) [2] => Array ( [about_us] => About Us ) [3] => Array ( [feedback_form] => Feedback Form ...

Zend Framework Cardinality violation: 1241 Operand should contain 1 column(s)

Hi guys, I have a sql problem and i don't know how to fix it, I have tried a few things but..you know.So here is my query: /** * Returns a list with all the months for the archive * * @return array */ public function Archive() { $q = "SELECT DISTINCT MONTH(`data`) AS `month`,YEAR(`data`) AS `year` FROM `posts` ORDER BY `data` D...

PHP array_key_exists() and SPL ArrayAccess interface: not compatible?

I wrote a simple collection class so that I can store my arrays in objects: class App_Collection implements ArrayAccess, IteratorAggregate, Countable { public $data = array(); public function count() { return count($this->data); } public function offsetExists($offset) { return (isset($this...

basic question about php multiple FOREACH loops

Hello! I have few FOREACH loops in php; $c1 = 1; $c2 = 1; $c3 = 1; foreach ($someArray as $a){ echo $a; if (sizeof($someArray != $c1){ echo " / "; } $c1++; } foreach ($otherArray as $b){ echo $b; if (sizeof($otherArray != $c2){ echo ", "; } $c2++; } // etc. This seems somehow stupid, of cou...

[PHP] Google Reader Unread Count

I wrote this function to get the unread count of google reader items. function GetUnread($sid) { $url = "http://www.google.com/reader/api/0/unread-count?all=true&output=xml"; $msg = urldecode($msg); $msg = stripslashes($msg); $msg = urlencode($msg); $url = $url . $msg; $purl = parse_url($url); $uri = $pu...

Zend Framework normal query to Zend_Db_Table

Here is my query: "SELECT * FROM `posts` WHERE MATCH(title, text) AGAINST('".$word."' IN BOOLEAN MODE)"; How can I do this with Zend_Db_Table, I mean($this->select()...) Best Regards! ...

filter_var versus preg_match

Morning all I'm converting a site that I'm working on to be compliant with the latest version of PHP, so I'm going through and replacing all instances of ereg with their non-depreciated equivalent. However I was told about a handy built-in function with PHP called filter_var. What my question is, is would it make sense to go with filte...

How to reset fckeditor with reset button in php or java script?

See the below Image. I have added a reset button at the end of form. When user press "reset" I can clear all inputs. But I don't know, how to clear this fckeditor values. Thanks in advance for helping me. Sagar. ...

Is there a way to maintain a 200MB immutable data structure in memory and access it from a script?

I have a list of 9 million IPs and, with a set of hash tables, I can make a constant-time function that returns if a particular IP is in that list. Can I do it in PHP? If so, how? ...

mySQL/PHP to update if the row exists or else insert when column to check is not unique

I have read about REPLACE and INSERT ON DUPLICATE key queries, and while I can see how useful they are, they don't appear to work for my purposes. Perhaps my database design is off from how it should be, but either way I hope I can get this working. I am trying to mock up an online store to teach myself mysql and php, and I am recording...

What features to be included into an e-commerce system written in php?

Hi, we are planning to buid an e-commerce system in php. We will not ship the products but offer them as download. What, in your opinion, are the technical must-haves of such a project? (databases, php modules, server ...). Thanks very much for your suggestions and tips ;9 best, heinrich ...

PHP Type Hinting: array supported, object NOT?

Am I missing something or there really is no support for generic object type hinting in PHP 5.x? I find it really strange that hinting arrays is supported while hinting objects is not, at least not out of the box. I'd like to have something like this: function foo(object $o) Just as we have: function foo(array $o) Example of poss...

Working with binary data in PHP

Hello, here are 5 binary strings base64_encode()'ed wAD4Af8B/gHuA/4BzgP1A/8P/h//f/xv+z30D9IDSAE= AAAgCPgf/B/4H/w1+B74Gfg/+B/8P/4f/D/8HwABAAA= AAAAAMB/wP/A/8B/4HvAf+B/+n/3P/Y//z/4n4CDgAE= AAAAXcB/wH/Af8B/wHfAP+B/6H/xf+7//r/4f0CngFY= AAiwifAP+B/4D/gf8B74D/gd8V/4H/gP8B/8vwABAAA= AAAAAAAA/QD/Af4B/iP+A/wD/A/+//7/...

SIMPLE PHP MVC Framework!

I need a simple and basic MVC example to get me started. I dont want to use any of the available packaged frameworks. I am in need of a simple example of a simple PHP MVC framework that would allow, at most, the basic creation of a simple multi-page site. I am asking for a simple example because I learn best from simple real world exam...

How can I find all matches of <element>something</element> with a regex?

So let's say that I have: <any_html_element>maybe some whitespaces <br/>Some text</any_html_element> And I want to remove the first <br/> after <any_html_element>. How can I do that? Best Regards ...