php

A simple PHP question.

I have a Joomla module that basically displays a list of categories. Next to the category name, the number of items in that particular category is displayed using the line below <em>(<?php echo $row->counter ;?>) </em> The items in the categories are set to either ‘open’, ‘close’ or ‘frozen’ and I am trying to make it so that it o...

PHP, MySQL, and AES Encryption / Decryption for User Data

I am new to AES encryption but trying to build a solution which: Accepts consumer data Encrypts that data using AES and a "public" key Store that data in a MySQL database Have the ability to pull and decrypt the data ONLY with a private key (stored on my personal machine, not the server itself). I realize this may be overkill but wan...

Can someone explain this strange mod_rewrite regex behavior

I've been working on a script for debugging mod_rewrite, and when testing their regex system I've had some strange results. I'm wondering if this is normal behavior for the mod_rewrite regex engine or if some part in my code is causing it. Requested URL: http://myurl.com/path/to/something .htaccess has: RewriteRule to where Using my d...

Displaying MySQL results from a relation of a relation

If I have three tables, and I'm trying to loop through all posts: posts: post_id, post_title, post_content tag_relations: post_id, tag_id tags: tag_ig, tag_name If each post will have multiple tags, how would I display each tag for each post? As in, how would I have to setup my SQL query, and how would I print the results? Would it b...

Programming by contracts in php

Programming by contracts is a modern (?) trend in .net. But what about libraries/frameworks for code contracts in php? What do you think about applicability of this paradigm for php? Googling of "code contracts php" gave nothing to me. UPD: for those who didn't even try to google for unknown term ("coding by contracts") and voted fo...

PHP Curl 302 authentication with cookies

I am trying to learn to use PHP curl and it seemed to go well until I have tried to authenticate to changeip.com. Here is the function I use to make a Curl call: function request($ch, $url, $params = array()) { $options = array ( CURLOPT_URL => $url, CURLOPT_USERAGENT => 'M...

How to cast a php array into javascript array

I run a mysql query and get the results successfully. However, I cannot read the elements of the array from javascript side. Can anyone help?? //JAVASCRIPT makes a request function profiles(){ $.post('dbConn.php', { opType:"getProfileList" }, fillProfileCombo, "text"); } function fillProfileCombo(res) { alert(res); } //dbConn.php...

Making a CSS background rectangle appear when a field equals 1

The code below echoes out an HTML table, populated with values from a MySQL database. The CSS changes when a field called "topten" equals 1. When "topten" equals 1, I would like to have a rectangular background 100 pixels high, 800 pixels wide, and color #A6FFFF;. When "topten" does not equal 1, I would like there to be no backgroun...

HTML textarea newline character

I have a text area in HTML where the user can enter text, but when the form is submitted, and its passed to a php script which echo's it, there aren't any newlines. Knowing that HTML does that, I tried doing a preg_replace() before echoing it... echo preg_replace("/\n/", "<br />", $_GET["text"]); but still everything is on one lin...

MySQL: Incorrect key file for table '/tmp/#sql_185e_0.MYI'; try to repair it

Hi, Incorrect key file for table '/tmp/#sql_185e_0.MYI'; try to repair it What does this error mean? "Incorrect key file for table '/tmp/#sql_185e_0.MYI'; try to repair it" I'm inserting 400k records in a table by 25k per batch using PHP in command line. If I inserted only 1k records then it will not produce the MySQL error. Does ...

Wordpress PHP: List categories without links?

Hello, I am using wordpress 3.01, and would like to list a number of child categories within a parent in this format. Without links. { 'cat1' , 'cat2' } Is this possible? http://codex.wordpress.org/Template_Tags/wp_list_categories this call seems like the right one, but I can't figure out how to list them without turning off links Th...

memcaching php resouce objects

Say I have this code in PHP : $query = mysql_query("SELECT ..."); the statement returns a resource object. Normally it would get passed to mysql_fetch_array() or one of the mysql_fetch_* functions to populate the data set. I'm wondering if the resouce object - the $query variable in this case can be cached in memcache and then a wh...

PHP generate an image combining several images on different "layers"

Hey there, I am trying to create a dynamic image that will be created from PHP using GD... What I need to do is be able to specify the layering of one image over another. The images are supposed to overlap slightly and get smaller as you move towards the right of the image... however the only way I can get php to render the images to th...

PHP exception Handling vs C#

this is a really basic question (I hope). Most of the exception handling I have done has been with c#. In c# any code that errors out in a try catch block is dealt with by the catch code. For example try { int divByZero=45/0; } catch(Exception ex) { errorCode.text=ex.message(); } The error would be displayed in errorCode.text. ...

Make form remember earlier submitted values with CodeIgniter

Hey guys, I have this contact form with codeigniter, and what I want to do is, when the form is submitted but does not pass validation, I want the fields to contain earlier submitted values. There's one thing though: when the form is loaded all the fields already have a certain value assigned, so for example the "name field" shows "nam...

PHP how do I allow users to customize html for their blog design?

A certain blogsite allow its users to fully customize the entire html page of their blogg, change doctype and all, and they use tags for where they want the user to dipslay things like titlename and amount of comments etc. i.e this is code you can edit and submit under blog design settings: <tag:archivelist> <li><a href="${A...

Wordpress: getting latest post/image to display on an external (Posterous) site template

Hi there, I have a site currently built on Wordpress. I have a requirement to pull out the "latest post" in a category (magazine issue), to allow the latest issue to be displayed in the sidebar of a Posterous blog template, either in an iframe or by other means. What's the best way to achieve this? Shall I write a custom PHP page which...

PHP on Windows: LDAP (5.2) or Fileinfo (5.3), but not both?

I have got PHP 5.2.14 running successfully on Windows, with the LDAP extension loading and working correctly. I installed 5.2 because it appeared to be that php_ldap.dll wasn't available for 5.3. Now it looks like the Fileinfo extension is only available for 5.3! (I'm a linux chap mostly, and have generally been sheltered in the happy...

Why is PHP mysqli prepared statement working but inserting all NULL values?

What would cause this? Code follows: $m = new mysqli($host,$user,$pass,$db); if(mysqli_connect_errno()) die('Connect failed: ' . mysqli_connect_error()); $PrepSQL = "INSERT INTO Products (" . implode(',',$this->cols) . ") VALUES ("; $PrepSQL .= '?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $stmt ...

In MySQL, is it faster to delete and then insert or is it faster to update existing rows?

First of all, let me just say that I'm using the PHP framework Yii, so I'd like to stay within its defined set of SQL statement if possible. I know I could probably create one huge long SQL statement that would do everything, but I'd rather not go there. OK, imagine I have a table Users and a table FavColors. Then I have a form where us...