php

With php cURL get filename from file header

Hello, I have this php cURL function: function curl_login($url,$data,$proxy,$proxystatus){ $fp = fopen("cookietlt.txt", "w"); fclose($fp); $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MS...

Working with multiple databases in php/mysql

I am working on a project needing me to work with multiple database connections. From what I have read, I should be able to switch between connections in the query itself, something like: mysql_query("SELECT * FROM user_types", $db_core)or die(mysql_error()); But I receive the error: Table 'db_company.user_types' doesn't exist So I...

PHP web-textbox syntax highlighting

I'm looking for a solution where users can copy/paste PHP code into a textbox and it will be highlighted like it is inside an IDE. (Like stackoverflow does when you paste a code snippet) Any links/ideas/more information would be appreciated. ...

New lines in a string with GD library

Is it possible? \n doesnt work, html doesnt work, nothing seems to work. I know I could just make a new string instead, but that is more effort than should be needed for this simple task. How can I do this? ...

Choosing between PHP frameworks and template systems

I have a moderately simple assignment, to create a PHP/PDO site with login functionality and article retrieve/save/edit/search. No tags, nothing else. Is this overkill to use some framework for this? It it a good decision to use custom code + perhaps template system like Smarty for a simple site that will not grow too much? Is there a ...

php call member variables off a class within static method

Hello, I am using some method to autoload helper files with functions The only problem I am having now, is how to call the variables in that class. Because I am not instantiating it as an object $this won't work. But what will?? class some_helperclass { var $some_variable = '007'; public static function some_func() { //ret...

php apache url rewrite

I have an url with the following format: domain/product.php?name=product a Now I need to rewrite this to: domain/product a(including the space in the word) like: http://www.directline-holidays.co.uk/Costa Blanca How do I do this? The closest result I got so far is the following: domain/p/product-a With the following code in .htaccess ...

How To Generate (Somewhat) Secure Passwords in PHP?

I'm trying to come up with a function that can generate random passwords, that must meet the following requirements: Between 8 & 14 characters Contain a least one of the following: lowercase letter, uppercase letter, punctuation, and number what would be the best way about going about this, such that the function can generate every p...

Experiencing difficult to reproduce bugs with jqUploader and am considering switching to Uploadify. Thoughts?

Hi, I've used jqUploader for a while but I find that it will occasionally fail to work on certain browsers on certain machines or will not work properly when using HTTP Basic authentication. I've tired of trying to get this to work properly and am considering switching to another (hopefully) less buggy uploader. I've looked into Uploadif...

Help with searchform with GET

OK If im on: index.php?area=characters and type in eg. Agamemnon Busmalis in the search field: <h2>Search Character</h2> <form action="?area=characters" method="get"> Name: <input type="text" name="name" /> </form> I want it do send me to : index.php?area=characters&name=Agamemnon+Busmalis but instead it sends me to: index.php?name...

Not using $_GET parameters

In working with CodeIgniter, it appears $_GET is disabled by default. I'm wondering why this is. A lot of times, I want to build very long search queries. So for example, I have a form that allows you to search the database by N different fields. In code igniter, the url to display my search result would be: http://mysite.com/field...

PHP 5.3 DateTime for recurring events

I have a calendar application which utilizes the newer PHP DateTime classes. I have a way that I handle recurring events, but it seems hack-ish and I wanted to see if you guys have better ideas: I have a recurring event that starts 11/16/2009 (Nov 16, 2009) It will occur every 3 days The event will recur indefinitely Let's say the us...

Placeholders using generic ODBC drivers

Currently, I'm peppering form submissions to account for single quotes & other garbage. $form_field_value= str_replace("'", "''", stripslashes($form_field_value)); It is to prep the value for insertion using: $insert_sql = "insert into table (field) values ('".$form_field_value."')"; odbc_exec($conn, $insert_sql); Essentially,...

Problem with Symfony routing with online project

I have a Symfony project on a Win XP / IIS 7 machine with Isapi rewrite installed. When I go to the frontend (my main) application, it seems that the routing simply doesn't work. I always end up on my default module/action. However, if I turn no_script_name = off (in the app's settings.yml file) then everything works fine. I also have an...

small error I cant find, please check this rename() function

Please have a quick look below, what is wrong here? $tmp_img_path="../temp_images/"; $name_image1="mypicture.jpeg"; $new_img_path="../images/"; rename($temp_img_path.$name_image1, $new_img_path.'thumbs/'); I want to find the file with filename $name_image1 and place it in the new path, but in a folder called 'thumbs'. I get warning r...

Basic foreach loop question

Thanks for the help here: http://stackoverflow.com/questions/1744128/foreach-loops-stdclass-objects I set up a foreach loop, but the problem is that sometimes the result is: Warning: Invalid argument supplied for foreach() in /home/MYACCOUNT/public_html/the script.php on line 81 I think that's when there is nothing to fill...

are scenarios/stories the new interface in BDD/TDD?

PHP is somewhat crippled since it doesn't have return types (yet). I need my code to throw an exception when X already exists. I can write this in a scenario, but I'm not able to go from the scenarios to the interface my class should implement. Actually this problem is the same in TDD I guess. There seems more that I can tell through my...

PHP: Tips on having different languages

We're taking our site international, .fr, .mx and soon some others. I was thinking of creating language files like english.inc.php that would have basically a big array of every static text that we use. For example $lang['welcome'] = 'Welcome'; I would dynamically include the correct language file based on the domain name used, and th...

Take a quick look at this for loop, what is wrong?

I have several variables named $name_image1, $name_image2 etc. (all ending with a nr). Can you see what I am trying to do here below: for ($i = 0; $i < $nr_of_pics; $i++){ rename( $temp_img_path . $name_image[$i], $new_img_path . 'thumbs/'.$name_image[$i] ); } I want to skip doing alot of if statements. Is it possible to alter a va...

On mac OS, I've enabled PHP but seem to have permission problems. How do I enable subdirectories?

Whenever I install a library that requires using subdirectories, it seems like I have to go to chmod hell. How can I make it where all subdirectories are accessible by PHP? C:\Library\Webserver\Documents is the current root of my webserver. ...