php

Does constantly checking the documentation make you a bad coder?

When writing PHP code for any given project, do you find you can write code off the top of your head? Or do you make multiple round trips to php.net? If it is the later, can you still be considered a good coder. This is a legitimate question as I find I have difficulty always remembering all of the functions that are available to me so I...

Off-site uploading

I need to somehow integrate off-site uploading onto my website, that is, so the uploading form itself is on my website but the file gets uploaded to a server somewhere else. I have experience in PHP file uploading and handling, but the files were all being transferred to the machine that held the form. This time I need it to upload dire...

Codeigniter Cart Class - additional price for product options

Is it possible to add price values to product options in the Codeigniter Cart Class. For example: T-shirt price is $10.00, but the XXL size is an extra $2.00. $data = array( 'id' => 'abc', 'qty' => 1, 'price' => 10.00, 'name' => 'T-Shirt', 'options' => array('Size' => ...

How to extract tags from XML

Hi, I have a simple XML extraction issue that should be solvable with straight PHP and not require any libraries. All I need to do is extract the values of one tag. For example, given the string of XML: <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ....> <Result>Foo</Result> <Result>Bar</Result> </ResultSet> I j...

PHP MYSQL FPDF retrieving pdf string stored as blob.

Using the above technologies, I want to create a PDF, store it in my db, and email it. All with the click of one button. I also want to call it up and have it be able to display with a hyperlink. I am very new to FPDF. Therefore, I am trying to start off very slowly. I began with this link stackoverflow Q I put both parts of his c...

php - efficent way to get and remove first line in file

Hello, I have a script that each time is called gets the 1st line of a file. Each line is known to be exactly of the same length (32 alphanumerci chars) and terminates with a "\r\n". After getting the 1st line, the script removes it. Now I do in this way: $contents = file_get_contents($file)); $first_line = substr($contents, 0, 32); f...

Time stamp and adding 1 year and last day in month

I have timestamp in DB like: 1268085720, its 2010-03-08 23:00, so its today. How can i add one year, and to be the last day in the same month, and need to convert it like: YYYY-MM-DD HH:MM? For given example i need 2011-03-31 23:59. Thanks ...

PHP driven site needs password change.

I have inherited a website that needs the password changed that accesses the database. I can see that there are two tables within the database but neither of them have username or password info. The previous web guy moved out of the country and can't be reached. I am not up-to-speed enough to figure this out. I have gone through all ...

PHP: how to know that all letters in a string are upper case?

How to know that all letters in a string are upper case? ...

Debugging a Browser Redirect Loop

Hi all, I am using CakePHP with the Auth and ACL components. My page loads fine for non-registered users, but if I try to log in as a registered user I get an infinite redirect loop in the browser. I am sure that this is some sort of permissions problem, but the problem exists even for users who have permissions for everything. The o...

echoing our parts of an Array?

I have the following array that I get as an output from facebook: http://www.paste.to/v/1jntlnml With the following code: $stream = $facebook->api_client->stream_get('',128342905144,'0','0',30,'','','',''); foreach($stream as $wallpost) { echo '<pre>'; print_r($wallpost); echo '</pre>'; } So I get the data that I need...

RDF Triple Visualizer - ARC2

Hi there does anyone know of any good software for visualising an rdf triple store as an actual graph? I am using an arc2 triplestore and have already tried the visualizer plug in that is available from semasols site but I cant get it to work: I keep getting theis error: XML Parsing Error: no element found Location: data:image/svg+xml;b...

OpenID PHP Library Janrain, and setting the Auth_OpenID_RAND_SOURCE to null

I was looking into using OpenID for an upcoming project I was going to be working on. After reading through some tutorials on Janrain's PHP implementation of OpenID and looking through the source code I uploaded it to my server and tested out the example script included with my Google ID and I was getting some errors about the Auth_OpenI...

jQuery DatePicker - defaultDate using $_GET['date']

I'm having troubles with the following code: <link type="text/css" href="http://jqueryui.com/latest/themes/base/jquery.ui.all.css" rel="stylesheet" /> <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.4.2.js"&gt;&lt;/script&gt; <script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/1.8rc1/jqu...

Updating the number of comment in a DB

I'm trying to update the comments column in one table (Entries), when a new row is added to another table (blog_comments). This code is inside of the PHP function that adds a comment to the DB: $count = mysql_query("SELECT COUNT(*) FROM blog_comments WHERE entry_title='$entry_title'"); $update = mysql_query("UPDATE Entries SET comme...

PHP Sessions vs. jQuery show()/hide()

I´m working with a purchase process. The process consists of 4 steps. The first two steps is where we take in all customer data. The 3rd step sends the data to our servers with AJAX and then shows a payment form. After payment the customer is thanked in step 4. My question is about Step 1 and Step 2. Right now all these steps are on the...

Removing title from wp_list_categories()

I'm trying to remove/replace the title attribute on the category elements used by WordPress. I'm using WordPress 2.9.1, with the following code: <div id="categories"> <h3>Manufacturers</h3> <ul> <?php str_replace("title=\"View all posts filed under ","",wp_list_categories('use_desc_for_title=0&exclude=1,2,3,4,5&t...

Is it okay to use array[key] in PHP?

Hi, I have a simple question. Is it okay to use array without single or double quotion like $array[key]? I thought it is bad because PHP look for constant first if I don't use single or doulbe quotion. One of my colleagues told me that it does not matter. WHat do you guys think? ...

Have to login twice. PHP sessions and login troubles with Chrome and Opera.

The problem I am encountering is that for my login form I have to login twice for the session to register properly, but only in Chrome (my version is 4.0.249.89) and Opera (my version is 10.10). Here is the stripped down code that I am testing on: Login Page: session_start(); $_SESSION['user_id'] = 8; $_SESSION['user_name'] = 'Jim'...

PHP: Filter array by prefix - what was that function's name?

Say I have an array with the following members: car_porsche car_mercedes car_toyota motorcycle_suzuki motorcycle_honda motorcycle_motoguzzi how can I get an array with all the elements starting with car_? There was a native function for this but I forgot its name. Do you know which function I mean? I know how to do it with for/forea...