php

PHP - Formula doesn't want to post with image

y0 c0derz! My formula looks like this: <form method="post" action="index.php?sida=upl" enctype="multipart/form-data" name="myform"> <input type="file" name="picture" id="picture" class="file_1" /> <input type="image" name="submit" style="margin-left: 120px;" src="uplbutt.png" /> </form> And the PHP code for the form...

Where do I put the "Allow Access to MyNewCoolApp?" screen in OAuth

Hi, i'm trying to get an OAuth server working but i'm kinda stuck a bit here because i've got it to get a "request token" but I don't know where I put this screen in. I'm using the library for PHP from http://oauth.googlecode.com/svn/code/php/ Thanks ...

PHP preg_split if not inside curly brackets

Hi all! I'm makin' a scripting language interpreter using PHP. I have this code in that scripting language: write {Hello, World!} in either the color {blue} or {red} or {#00AA00} and in either the font {Arial Black} or {Monaco} where both the color and the font are determined randomly (Yes, it's hard to believe but that's the syntax)...

Using wildcards in prepared statement - MySQLi

Hi! I'm trying to run the following query, and I'm having trouble with the wildcard. function getStudents() { global $db; $users = array(); $query = $db->prepare("SELECT id, adminRights FROM users WHERE classes LIKE ? && adminRights='student'"); $query->bind_param('s', '%' . $this->className . '%'); $query->...

regex php: find everything in div

I'm trying to find eveything inside a div using regexp. I'm aware that there probably is a smarter way to do this - but I've chosen regexp. so currently my regexp pattern looks like this: $gallery_pattern = '/([\s\S]*)<\/div>/'; And it does the trick - somewhat. the problem is if i have two divs after each other - like this. <div c...

PHP language detection

Hi! Im a hobbycoder that is trying to build his first multilangual site I use this piece of code to detect users language. If you havent chosen a language it will include your language file based on HTTP_ACCEPT_LANGUAGE i dont know where it gets it from tho.. session_start(); if (!isset($_SESSION['lang'])) { $_SESSION['lang'] = sub...

get json array back through javascript in jquery

Hey I have an external file in php, outputed as json format I want the data to be send back to jquery in arrays .... how to do it ? php: $options = "<option value="data0">data 0<option> <option value="data1">data 1<option> <option value="data2">data 2<option> <option value="data3">data 3<option> <option value="data4">data 4<option...

Exclude ASP.NET from subfolders

I have an application that runs on a shared hosting website - it is running ASP.NET MVC, however one of the folders within the application, /community/, is just a standalone message board application (Invision Power Board), running in php. I keep getting problems with the web.config from the asp.net application trying to apply itself to...

Rescuing corrupted characters in database

I have just imported a huge MySQL database. Most fields are latin1_swedish_ci, and they contain lots of corrupted strings. e.g. Cavit Y�r�kl� instead of Cavit Yürüklü I have been trying to find a solution to fix these corruptions using PHP as thats all I know a little bit of. I have played unsuccessfully with utf8_(en|de...

serialize/unserialize in jQuery

Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string representations of an array or an object which can than be decoded back into array/object. http://sk2.php.net/serialize ...

How do I perform an additional action only on the first iteration of a loop?

I know how to do this... I'll give example code below. But I can't shake the feeling that there's a clever way to accomplish what I want to do without using a variable like $isfirstloop. $isfirstloop = true; foreach($arrayname as $value) { if ($isfirstloop) { dosomethingspecial(); $isfirstloop = false; } dosomething(); } Is th...

Opening SQLite3 as READONLY with PDO?

The SQLite3 Class has an option like this. $db = new SQLite3('mysqlitedb.db', SQLITE3_OPEN_READONLY); In PDO you would simply open with: $db = new PDO('sqlite:mysqlitedb.db'); My question is however, is there a way to open a database with PDO, in READONLY mode? ...

Designing a database for user-customized groupings

A user can search for colours and add them to their palette.. So if they write blue, blue will show up and they can add it. so on with red, yellow....... But I want, that if they choose "dark colors", then grey black and brown should be added. Today I´m doing like this if($color==darkcolor) insert black and grey and brown... Is ...

jQuery + hidden input fields

A simplified version of problem I am experiencing: Here is my HTML form: <form enctype="multipart/form-data" method="post" action="/controller/action"> <input type="text" name="title" id="title" value="" class="input-text" /> <input type="hidden" name="hidden_field" value="" id="hidden_field" /> <input type="submit" name="submit_form" ...

How can I tell what line a file resource is currently "on" in PHP?

Using PHP, it's possible to read off the contents of a file using fopen and fgets. Each time fgets is called, it returns the next line in the file. How does fgets know what line to read? In other words, how does it know that it last read line 5, so it should return the contents of line 6 this time? Is there a way for me to access tha...

How to match a quoted string with escaped quotes in it?

/^"((?:[^"]|\\.)*)"/ Against this string: "quote\_with\\escaped\"characters" more It only matches until the \", although I've clearly defined \ as an escape character (and it matches \_ and \\ fine...). ...

Source install Apache 2.2.13 + PHP 5.3 + Snow Leopard

Can anyone direct me to or write their experiences installing Apache and PHP on Snow Leopard? I had this working in the past on Leopard, it would die after a security update, but was as simple as: $ ./configure --enable-layout=Darwin --enable-mods-shared=all $ make $ sudo make install and I was up and running again. Since the Snow L...

Looking for ideas/solutions to manage application configuration settings

I'm building an MVC framework in PHP that will need to set a number of default configuration variables/constants. Example config vars would be where to save log files, whether to log queries, Doctrine settings, amongst many others. Because I want developers to be able to create new projects with minimal fuss, these config vars should hav...

xgettext vs gettext

I have a few questions: I know what gettext is. I've read a few posts where they mentioned xgettext and was curious as to what is the difference between the two. How can I install xgettext on Windows? And finally, does anybody have a tutorial on how to install the library php-gettext http://savannah.nongnu.org/projects/php-gettext/ ...

Dynamically change url or WordPress theme if UserAgent is iPhone.

Is there any way to do this? My website is http://kennethreitz.com. Its driven by some moderate PHP on top Wordpress. My options are to detect if the user is using an iphone, and if they are either a) tell wordpress to load a different "theme" that i have written. b) if this isn't possible, have a different wordpress installation on ...