php

PHP + MySQL Queue

I need a simple table that acts as a Queue. My MySQL server restriction is I can't use InnoDB tables, only MyISAM. Clients/workers will work at the same time and they will need to receive differents jobs each time. My idea is to do the following (pseudo-code): $job <- SELECT * FROM queue ORDER BY last_pop ASC LIMIT 1; UPDATE queue SET...

Complicated MySQL Query

I'm creating a site in wordpress which holds information on television programs. I'm using custom fields to select each post. The table looks something like this +----+---------+----------+------------+ | id | post_id | meta_key | meta_value | +----+---------+----------+------------+ | 1 | 1 | name | Smallville | | 2 | 1...

ASP.NET developer trying to learn Drupal and PHP

Hi guys, I know ASP.NET C# very well. I make a lot of stuff like surveys and custom web applications. I'm having a lot of trouble wrapping my head around Drupal and figuring out how to do 'special' programmatic things, like searching a list of clients, or creating a web application. 1 - I've been reading books and drupal API but I'm ...

Getting data back AND $POSTing data using jQuery.Ajax

I'm trying to build a registration system using PHP and the AJAX components of jquery. My jQuery takes the values of the username and password fields and makes a POST request to the PHP script, which grabs the values using $_POST and saves them to the database. Of course, i'm wanting to make sure that there aren't any duplicate usernam...

How do I write an IF statment in php that checks for dupliate database entries

How do I write an IF statment in php that checks a database for $varialbe and have it only perform the action if $varialbe is not already in the database. ...

How to store NULL values in datetime fields in MySQL?

I have a "bill_date" field that I want to be blank (NULL) until it's been billed, at which point the date will be entered. I see that MySQL does not like NULL values in datetime fields. Do any of you have a simple way to handle this, or am I forced to use the min date as a "NULL equivalent" and then check for that date? Thanks. EDITED...

How do you count the number of times any given $variable appears in a column in a MySql table

How do you count the number of times any given $variable appears in a MySQL Table The database name is STUDENTS The table is called PROJECTS The column is called ESSAYS The variable for each essay is what im trying to count. It is called &essay and inserts into PROJECTS ...

Putting spaces into a PHP date format

Hello, In the PHP date function below, I would like to put a few spaces between "a" and "\N\e\w". How is it done? 'l, F j, Y, g:i a \N\e\w \Y\o\r\k \t\i\m\e' Thanks in advance, John ...

jquery ajax with memcache and php objects

Hi hope I'll be able to explain my needs clearly... :) . I have a HTML document generated by a PHP script that contains some objects stored in memcache. The PHP script uses these objects to populate the HTML elements and create a structure like this: //$day is an array of objects pulled from memcache <ul id="day"> <?php foreach($day ...

PHP + MySQL Cycle Queue

I just accepted a similar question (http://stackoverflow.com/questions/1690748/php-mysql-queue), but I realized that it wasn't the correct question for my problem, but was the correct answer for my question :) I have a MySQL (MyISAM type) table of sites to be scraped by workers. CREATE TABLE `site` ( `id` int(11) NOT NULL auto_increm...

Business layer, data layer, where to put queries?

I have a data access layer that has separate classes for each table in the database. Each class makes objects that reference a row in the table, they have create, update, delete, and fetch functions. They all extend a DBObj class. My question is, say I want to write a query to SELECT * FROM table, and have that in a function. Where is th...

PHP mysqli_fetch_field data type

Hi folks, I need some help tracking down a bit of nitty gritty information on the information in the fetch_field method of a mysqli result object. Specifically the type property - from the documentation it would seem that this field returns an integer... Great! I just can't seem to find a table that will let me translate the number t...

SQL Syntax Error - PHP/MySQL

Can anyone tell me what's going on here. I'm not sure why this code is not working and throwing the following error: You have an error in your SQL syntax, check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND role != 7 AND role != 4' at line 3 $sql = 'SELECT * FROM tblusers INNER...

What do these PHP mbstring settings do?

I'm trying to figure out exactly what these php.ini settings do. What happens when they're set to different values? When are they necessary? When are they harmful? mbstring.language mbstring.http_input mbstring.http_output mbstring.encoding_translation As usual, the PHP manual is less than helpful. EDIT: Just to clarify, I understan...

Sending a file via HTTP PUT in PHP

I've been struggling for several hours trying to figure out how to get this work. I'm trying to send a file via HTTP-PUT to an eXist db. There is user authentication for the server, so I was trying to do something like this: I have the URL where the doc is to be PUTted to I have the username and password for the eXist DB I have the co...

PHP: How to remove first link from string?

How to remove first link with image from this text with PHP? <a href="some link"><img src="image link" /></a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.** ...

PHP Echo text Color

How do I change the color of an echo message and center the message in the PHP I've written. The line I have is: echo 'Request has been sent. Please wait for my reply!'; ...

PHP how can i get the full url

how can i get the full url like:http://www.domain.com/page.php?id=someid&amp;page=1 ? not just http://www.domain.com/page.php ...

Specify which model relations to load

I am a beginning Cake user but well versed in php and frame works in general (I used to use Code Igniter). How can I call the model below and only return the Artist records and the related ArtistImage records, not the Album records. class Artist extends AppModel { var $name = 'Artist'; var $hasMany = array('Album', 'ArtistImage'); ...

Handling Google OpenID

I'm trying to implement Google OpenID for my website, but I'm struggling to figure out how to handle the OpenID response I get. At the moment, when you click a login button, it takes you to the Google site, asks you to login there and when i click 'Sign In' it takes me back to my site and I get the followingi n the URL: http://mysite.c...