php

Best approach for a PHP addons/mods manager?

This question isn't really limited to PHP but more of a "best way to do this..." kind of thing. I was hoping to include some kind of user-created addon manager to my next PHP application (without users having to manually edit files, and without the the addons becoming all mixed up), but I'm pretty stumped as to how it could best be done...

PHP Date format question....

Hi guys. Some folks helped me on http://stackoverflow.com/questions/3326316/how-to-check-the-data-format-in-php post but I need to check two date formats MM-DD-YYYY and DD-MM-YY instead of one. Do I need to setup two regular expression???? Thanks for the help!!! $date1=05/25/2010; $date2=25/05/10; //I wish both of them would...

How do I go straight to the shopping cart with the item added

So I am trying add an item to the shopping cart without clicking on the add to cart in miva. For example I go here http://posnation.com/pos_knowledge and i click on the Buy now button it takes me to http://posnation.com/pos_support/online_kbase but on that page there is an add to cart button, if you hit it the item gets added to...

Date regular expression question...

Hi guys.. I have been working on my date regular expression all day... I want a date format to be YYYY-MM-DD. $date_regex ='^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$'; if (preg_match($date_regex, $dateString)) { echo "good format"; } keeps giving me error preg_match() [function.preg-match]: No e...

How to access my singletons without using global state?

I know that Singleton pattern is bad because it uses global state. But in most applications, you need to have a single instance of a class, like a database connection. So I designed my Database object without using the singleton pattern but I instanciate it only once. My question is, how can I access my object in the low level classes ...

Getting $_GET to work with Codeigniter

I've seen several examples but i can't seem to get it working. Config.php: $config['uri_protocol'] = "PATH_INFO"; $config['enable_query_strings'] = TRUE; Library: class MY_Input extends CI_Input { function _sanitize_globals() { $this->allow_get_array = TRUE; parent::_sanitize_globals(); ...

How to get the headers from the last redirect with PHP's curl functions?

If I execute a cURL request that is set to follow redirects and return the headers, it returns the headers for ALL of the redirects. I only want the last header returned (and the content body). How do I achieve that? ...

Write to text file problem in PHP

I have this page called up.php that adds 1 to a txt file set with all permissions. <?php $name = file_get_contents("name.txt"); if(!file_exists('number.txt')){ file_put_contents('number.txt', ((int) file_get_contents('number.txt')) + 1); header('Location: "$name.txt"); } ?> I have a form action button that runs this php page, how...

PHP..How to print month only from a date variable...

Hi guys.. I have a date variable like 10-25-1998 and I only want to echo 10. Can anyone help me about it? Thanks... $dateString=date("m-d-Y", mktime(0,0,0,10,25,1998)); echo date('m', $dateString); // not working here....will print out 01 ...

unable to set Error Message for email validation-Zend-form

This is strange. I'm trying to set the error message for my email validation element in Zend form. Other fields are working correctly-but not email-what's up? code bit: $name = new Zend_Form_Element_Text('name'); $name ->setLabel('Name:') ->setRequired(true) ->addValidator('Alnum') ...

PHP "dynamic" Menu

I am just starting PHP (as in today). I want to create a customizable menu using a jquery script that can have a variable amount of items. I am getting an error when i run this. The error is: Parse error: syntax error, unexpected T_VARIABLE in /home/s0urc3/public_html/files01/menu.php on line 5 Thanks to Chase for his answer inde...

Test and echo without repetition?

This is a minor thing, but it's been bugging me for a while. I've wracked my brain for a way to write statements like this without any repetition of code. For example: echo isset($array[0])? $array[0]: 'not set'; $var = empty($other_var)? '$other_var not set': $other_var; Is there some sort of test-and-return (for the former) or tes...

How can I type in a textbox and have whatever I typed simultaneously appear in a div?

Hello All, I want to have it so when I type into a textbox (or an input field) and have whatever I am typing simultaneously appear in a div or just other place on the page? The stackoverflow site does this when we type up a question. As we type a question, it shows whatever we are typing in a box below the textbox. Hope my question mak...

How to add custom javascript to WordPress Admin?

I want to add some custom jquery code to the Edit Post page, something really simple like showing a div when someone presses Publish. The only restriction is that I want to achieve this through the use of a plugin, not hacking the admin template files. I've tried echoing some script tags using some actions but it doesn't seem to be the...

Routes on zend modules

Hello, I want to make a kind of alias for my modules: Is there a way to make http://www.example.com/news point to /modules/news/controller/news/->action index. And if i go to http://www.example.com/news/show it automaticly points to /modules/news/controller/news/ -> action show Or do I have to make a route for every single action...

CodeIgniter :: how to resize and watermark image without saving it to hard disk

I'm having a problem: I want to resize and watermark an image in CodeIgniter. But I need "dynamic_output" to be TRUE. $this->image_lib->resize(); $this->image_lib->watermark(); But when resize function fires it returns the image directly. I don't need to save the image to save temporary copy. Any help? ...

MySQL Database doesn't exist, queries are automatically shunted to the correct db?

This is quite odd, but I have a script that was until now calling queries on a db that existed only on another server, and is now on my new server with a different name. However, the "host" was always localhost. The user connected to the non-existent DB on localhost, and somehow connected to the existing database instead? Can someone p...

How to Bind the Onclick event In Jquery in correspondance to Javascript

I Have a select button in php code which Passes the Dynamic generated Row value and How do i do this jquery? PHP code <input type ="button" onclick="select(add,'<?php echo $_POST['somevale=ue']?>')" Javascript function select (fnname, val){ //Val changes every time } How do i acheive the same in Jquery in Putting the click e...

PHP+XHTML+CSS+JS - Syntax Highlight

Hi Does anyone know a website where you can paste some code and it generates highlighted source code? As HTML, like Geshi, with span tags with color styles on them? ...

in_array returning false when should return true

I've got a simple script that takes a word from a form and assesses whether it exists in a file (.txt). The txt file has a single word or phrase on each line. There are no \t's or \r in the file. However, when I submit the form, and POST the first word in the file (e.g. "the"), the following script returns false, when it should return ...