php

Inserting and retrieving id before form is submitted

Here is what i'm trying to do: I have a form with few text fields and image upload via JavaScript(to have that loading animation). here is the link http://netfecs.com/inprogress/phat_cat/admin_edit_car.php?id=4 I'm using row id as part of the image name in the database. What is a good way to set the id and retrieve if before submitti...

Why can't I set zero as the first key in the array?

The result of this code: for($i = 0; $i <= 7; $i++){ $eachone[] = array ('a' => '1', 'b' => '2', 'c' => '3'); $a[] = array($i => $eachone); unset($eachone); } $json_string = json_encode($a); echo $json_string; is: [ [ [ { "a": "1", "b": "2", "c": "3" ...

PHP Variable problem!

So I have a PHP variable that's value get's replaced from another PHP file. Example: $var = "~~~OtherVariable~~~"; If I echo this variable out, it prints out the appropriate string. Example: echo $var; //prints out "This is a string of text"; So it looks like everything is working thus far, my PHP variable ($var) shows that it actu...

Zend Framework Upload Problem

90% of images that I upload with Zend Framework work great and they can be displayed in the browser without a problem but sometimes there si an image that gets uploaded without error yet when I try to display it in the browser I get this error (from time to time, sometimes the image will start loading but it will take ages and it won't l...

convert #RRGGBB hex value to #AARRGGBB

Hello, What value would have #414141 as #AARRGGBB and what about #52b531? How can I convert this using PHP? Regards, Pentium10 ...

POSTing Form Fields with same Name Attribute

If you have a form that POSTs to a PHP file and there are text inputs in the form with duplicate name attributes, will you still be able to obtain the values of both fields from the $_POST array? ...

How to get linux console $COLUMNS and $ROWS from PHP cli?

I'm currently creating a new neat CLI library for PHP, and i'd like to figure out the width/height of the console it's running in. I've tried many things like digging through $_ENV, exec("echo $COLUMNS"), etc, but no result, while if i type echo $COLUMNS or $ROWS in bash commandline, it neatly displays the value. What do i need to do ...

use php array in javascript?

my php code looks like this: $result['firstName']['lastName']='johan'; echo json_encode($result); how should i type to use this array in javascript with jquery? ...function(data) { alert(data.firstName.lastName); }); or ...function(data) { alert(data.firstName['lastName']); }); ...

how to create a factory that dynamicly extend a class so its type changes but it inherents parent methods.

What I would like to do is have a static factory function that you give it a series of attributes and it returns an object that is of a previously undeclared class that extends a known class. Basically: <?php class foo{ public $a; function increment($b = 1){ $this->a += $b; } } function factory($name, $a){ //returns an ob...

Safely using prepared statements to query database

I'm trying to write a function that is versatile in the queries it is allowed to make, but also safe from injection. The code below throws an error as is, but if I run it with 'name' instead of ':field' it works fine. $field = "name"; $value = "joe"; function selectquery($field, $value) { global $dbcon; $select = $dbcon->prepare...

What effects drawing charts/diagrams from $_SESSION data under php5, which worked under php4?

Hello, I have a script generating 3 diagrams from $_SESSION variables which work fine under php4 with register_globals = off, but when I parse the same script as php5 I get no diagram. The diagrams a drawn from GD libary and it works, if I set the data into an Array (manually filled) within the script file. But I need a way to get it w...

Return a reference to an instance of an object in PHP

I have a singleton factory and would like it to return a reference to the object instance so that I can use the singleton factory to destroy the instance and not have instances elsewhere in my code to survive. Example of what I would like to be able to do: $cat = CatFactory::getInstance(); $cat->talk(); //echos 'meow' CatFactory::destr...

PHP filesize() works on all but one file, gives stat failed error

I'm writing a PHP page that generates a podcast feed by scraping an existing HTML page. Everything works great, but one of my mp3 files gives a "filesize(): stat failed" error. As best as I can tell, the file isn't corrupted, and it plays perfectly fine. I've also reuploaded the file to the server. It falls in the middle range of all the...

Help me convert this 2d array code from PHP to C#

Please help me re-write this code sample in PHP to C#: $stringArray = array(); $stringArray['field1'] = 'value1'; $stringArray['field2'] = 'value2'; $stringArray['field3'] = 'value3'; foreach ($stringArray as $key => $value) { echo $key . ': ' . $value; echo "\r\n"; } ...

SQL clause to optimize UPDATE queries?

In my fictional database, I have several columns of data. In designing a PHP front-end to the script, it was necessary to allow the user to modify all attributes of a tuple if necessary. If the end-user only ends up modifying one attribute instead of all of them, the following statement: UPDATE foo SET name='bar' location='YYZ' dri...

difference between extension and plugin?

what is the actual difference between a extension and plugin? eg. is phplivex a extension or plugin? i have to know in which folder i should put it in ...

hiphop PHP download?

Where can you download the HipHop Code? I would really like to test it. Interestingly enough if you go here: http://github.com/facebook/hiphop-php/wikis It must not exist or private because it redirects to github.com index.php page So you can not even see the wiki or anything ...

singular or plural on models controllers?

if i've got a thread model and controller. should that be in singular or plural for both the model and controller? i could show a thread and also list threads. dont know what i should use. $thread->get_lists(); // doesnt sound good $threads->show(); // doesnt sound good ...

How to design a static/dynamic survey application?

I'm struggling here a lot really. I need to prepare a form that is something between static and dynamic. Basically on the first part of the survey you get a question asking you to select items from the checklist. You select the items and then you are presented with a list of n number of questions. Now, some facts: the questions and p...

Advanced many2many query for MYSQL

I im trying to build a imagegallery where people have access to different groups and the groups decide what catalogues and images they are allowed to see. I though many2many structure would be best for this. So far, ive manage to build the database like this: image (image_name, image_file, image_id) catalog (catalog_id, catalog_nam...