php

PHP alternatives?

Are there alternatives to PHP that perform faster and have somewhat the same feature set (like support for common RDBMS, Curl, Regex, etc)? What about coding websites in C? How does that work out? Is that platform independent and works on each server? ...

PHP object like array

I need to be able to set my object like this: $obj->foo = 'bar'; then after that is set i need the following to be true if($obj['foo'] == 'bar'){ //more code here } ...

Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.

I get the following error in Chrome every time I try to run my script on a Linux server: Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error. In Firefox it just shows a blank white page. Whenever I run it on my local test server (IIS on Windows 7) it runs exactly the way it should with no errors. I am pretty sure that it is a problem wi...

Date Range Query MySQL

I need a query to select data between two dates with today's date as a reference. The database has a datetime field for "start" and a datetime field for "end". $todays_date = date("Y-m-d H:i:s"); $q = "SELECT * FROM news WHERE `end` >= '" . $todays_date . "' AND `start` >= '" . $todays_date . "' ORDER BY id DESC"; The problem is t...

Best way to place data in the view (MVC)

In the framework I am working with, if I want to present data in a view I do this: <h1><?php echo $this->header ?></h1> Recently I discovered xTemplate and noticed it uses string placeholders, so the above code in a xTemplate would be: <h1>{HEADER}</h1> I always thought that a little php in the view was ok and was also faster than ...

site is auto including some thing from other site

my site is automatically getting download from other site when ever i try to open my site after opening my site it trys to download any thing from this address.... google-sk.pch.com.tagged-com.superore.ru please help me what's going on.... ...

PHP - Doctrine ORM not able to handle bit(1) types correctly?

UPDATE I have filed a bug in Doctrine about this http://www.doctrine-project.org/jira/browse/DC-400 I have the following Doctrine schema: --- TestTable: columns: bitty: bit(1) I have created the database and table for this. I then have the following PHP code: $obj1 = new TestTable(); $obj1['bitty'] = b'0'; $obj1->save();...

Why does this code work on PHP Version 5.2.10 and not on PHP Version 5.2.10-2?

With this code I am iterating trough an object. Why is this working on my WAMP box with PHP 5.2.10 and isn't it on my Ubuntu 9.10 installation with PHP 5.2.10-2 from the repo's? $incomingData = json_decode($_POST['data']); foreach($incomingData as $key => $action) { } Invalid argument supplied for foreach() ...

How to use getenv() in php and SetEnv in a .htaccess with a compiled php-cgi on a shared host

Just putting in context to clarify the main question: On my development machine, PHP5.3.1 is installed on Apache as a module, I use SetEnv APPLICATION_ENVIRONMENT development in my application's root .htaccess file. It is then easily retrievable from any php script with getenv('APPLICATION_ENVIRONMENT'). On the production server, on a ...

Regex to parse out title of a post

I'm using cURL to grab a page and I want to parse out the title of the post (the actual text shown on the link, not the title attribute of the <a>). The HTML is like this: <li class="topic"> <a title="Permanent Link to Blog Post" rel="bookmark" href="http://www.website.com/blog-post/"&gt;Title of blog post</a> </li> I tried using...

Is there a standard way to handle design (CSS) seperate from conditionals in PHP?

Hi folks, I've been working with a developer on a web-based application. I have some experience with html and css mainly, and now that the heavy lifting is done, I'm wanting to start improving the design elements of the program (I know that is NOT the ideal situation, and in a perfect world, all design elements would have been consider...

Get class name dynamically with jquery

I am trying to get this class name dynamically in jquery: echo "<div id=\"maini\" class=\"type_" .$category. " start_" .$adSize. " color_" .$color. "\"> \n"; echo " " . $siteName . " \n"; echo "</div> \n"; as you can see the class name is generated with PHP. I need the class name for this snippet of code. But what I tried does...

Mysql. Limit $x1, $x2. Is it possible to do Limit $x2, $x1?

For example, $x1 = 10, $x2 = 25 then it will work Limit $x1, $x2. But I want to make Limit $x2, $x1 and it doesn't work. I want to get from newest to oldest entry from that list. ORDER BY doesn't work edited you can close it, I've figured out by myself. I use ORDER BY a_time DESC LIMIT $x2-$x1 now, so thanks. ...

Post to twitter help - using php

I am trying to post a url to twitter but the url is user generated and dynamic... <a href="http://twitter.com/?status=[urlencode('I'd like to borrow this item @neighborrow')].">TWEET THIS REQUEST</a> i started with that but its not catching the actual url- then i tried a few others but they seem to be for static urls do i have to us...

Unsetting array values in a foreach loop.

I have a foreach loop set up to go through my array, check for a certain link, and if it finds it removes that link from the array. My code: foreach($images as $image) { if($image == 'http://i27.tinypic.com/29yk345.gif' || $image == 'http://img3.abload.de/img/10nx2340fhco.gif' || $image == 'http://i42.tinypic.com/9pp2456x.g...

Cropping image in PHP

I'd like crop an image in PHP and save the file. I know your supposed to use the GD library but i'm not sure how. Any ideas? Thanks ...

Drupal6: Trying to get errors from node_validate()

I'm trying to validate a set of nodes before saving them to the database: foreach ($nodes_to_save as $node) { if (! (node_validate($node, $form))) { form_set_error('', t('Node %title did not validate. No nodes were saved.', array('%title' => $node->title))); $success = FALSE; break; } } The documentatio...

PHPDoc for variable-length arrays of arguments.

Is there a syntax for documenting functions which take a single configuration array, rather than individual parameters? I'm thinking specifically of CodeIgniter-style libraries, which use a mechanism similar to this: <?php // // Library definition // class MyLibrary { var $foo; var $bar; var $baz; // ... and many more vars......

mysql insert random unique 8 chars

hello i'm using PHP , Mysql i have a table with 3 fields (( ID , Username , PID )). i want 'PID field' to contain string of 8 unique chars. my solution is to generate the random string in PHP and check if it's exists if it's exists then it will generate another string . is there any better solution that will save processing time lik...

MVC authentication - it's own model?

I have a social network-esque site with a nice User model that seems to be covering all my bases right now. I am reworking the code from spaghetti and want to find the best-practice solution for logging in / registering a user. Here are my options (I think): Create a separate Auth class (model?) that simply searches for a record of a ...