php

MySQL Transaction across many PHP Requests

I would like to create an interface for manipulating invoices in a transaction-like manner. The database consists of an invoices table, which holds billing information, and an invoice_lines table, which holds line items for the invoices. The website is a set of scripts which allow the addition, modification, and removal of invoices and...

Fix Size of Login Box in Drupal Theme

I've asked this question previously here, and thought it was fixed, however, it is only fixed in firefox. In Safari the login box is now very wide, jutting out over the page contents. Here is what it looks like in Safari, and here is what it looks like in Firefox. I originally went about fixing it by creating a drupal module which chan...

Measuring online time on website

Hello! I would like to measure how much time a user spends on my website. It's needed for a community site where you can say: "User X has been spending 1397 minutes here." After reading some documents about this, I know that there is no perfect way to achieve this. You can't measure the exact time. But I'm looking for an approach which...

Saving images client-side for compression/manipulation before upload to server

I've developed a PHP script to upload images to the server. It uploads the image, then reduces the image height, width and resolution server-side, thus reducing the file size a great deal. The problem is, if the user uploads images of say 4MB, it takes forever to upload. As the tool allows the user to upload up to 5 images per submission...

PHP check to see if a string matches a pattern

If I need a string to match this pattern: "word1,word2,word3", how would I check the string to make sure it fits that, in PHP? I want to make sure the string fits any of these patterns: word word1,word2 word1,word2,word3, word1,word2,word3,word4,etc. ...

Double Underscore in PHP?

What does the double underscores in these lines of PHP code mean? $WPLD_Trans['Yes']=__('Yes',$WPLD_Domain); $WPLD_Trans['No']=__('No',$WPLD_Domain); ...

Select From One Table And Include Sum Value From Another

My title is terrible but I'm having a hard time wrapping my head around this. I have two tables. Links and Votes. Links contain info about links submitted and the usual jazz, votes contains a foreign key link_id and a karma_up and karma_down value (both unsigned ints). Because I want to limit votes to one per user and record vote tim...

PHP json_decode on a 32bit server

Hi, im writting a twitter mashup service. When i receive the json data, some of the twit ids are greater than 2147483647 (which is the maximum allowed integer on 32bit servers). I came up with a solution that works, which is converting the integers to strings; that way the json_decode() function won't have any problems when trying to ge...

how to find first day of the next month and remain days to this date with php

Hi, How can i find first day of the next month and remain days to this day from present ? Thank you ...

Good books on Software Engineering for web apps?

Hi, could you guys recommend good Software Engineering books for web apps? [Edit] Thank you for the replies! I forgot to mention that I'm aiming to develop in PHP. Keep those suggestions coming and thanks a bunch! :) ...

My autogenerating xml sitemap code works very slowly, could I improve its performance ?

I have written an autogenerating sitemap code below, it is called every 12 hours. It looks through the mysql database, and then generates the input into the xml file for every row it finds in the mysql table. I am not the best PHP coder, so I hope you guys can help me improve this below. It works and does the job, but having over 400th...

PHP: Preventing Session Hijacking with token stored as a cookie?

Hi. I'm working on an RIA in PHP. To try to prevent session hijacking I introduced a token, generated at login, based off a salt, ISO-8601 week number and the user's IP. $salt = "blahblahblah"; $tokenstr = date('W') . $salt . $_SERVER['REMOTE_ADDR']; $token_md5 = md5($tokenstr); define("token_md5", $token_md5); Currently, it's...

what are the consequences of storing more variables in session??

whats the performance issues when we are storing 2-3 extra variables in session?? for: to save 1-2 queries(per page load)? To make code simpler? Hit rate to the website is normal.. Edit @all I m talking about two three session variables...simple values like number,ids etc ...

Tutorial for converting PHP applications to Cocoa?

I do a lot of coding in PHP and MySQL, but I'm looking at moving my applications to a desktop environment in order to allow users to access the data offline, and periodically receive updates from a central online database. For the time being, however, I'm looking for a decent tutorial on how to convert PHP applications to Cocoa, and how...

PHP if-statement using $_POST variable doesn't seem to work. Why?

On one PHP server I have two files. One file (the name is "first.php") contains this code: <html> <head> <title>First Page</title> </head> <body> Please enter your password and age: <form action="pass.php" method="post"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body...

PHP images add txt

I am trying to get it to show text1 and text2 on the same image only Text1 is showing up $rImg = ImageCreateFromJPEG("test.jpg"); $cor = imagecolorallocate($rImg, 0, 0, 0); imagestring($rImg,5,126,22,"Text1",$cor); imagestring($rImg,5,500,34,"Text2",$cor); header('Content-type: image/jpeg'); imagejpeg($rImg,NULL,100); Thank you ...

is it possible to execute a portion of a php script to see what it does?

i am pulling apart a third party shopping cart and they have included a bunch of junk (as usual) aside from having to remove and bring back pieces of code to see what it does. is it possible to execute a few lines? although setting up comments on codes i dont want to execute sounds good which i just thought of :p but what other things ...

oci_fetch_array() error message

error message: oci_fetch_array() expects parameter 1 to be resource, boolean given in /url_fns.php on line 17 I want to get all bm_URL record and store in $url_array. echo $r is shown to be 1. How to fix this error message? $conn = db_connect(); $result = oci_parse($conn, "select bm_URL from bookmark ...

Why do I get "Resource id #4" when I apply print_r() to an array in PHP?

Below is the code: $result=mysql_query("select * from choices where a_id='$taskid'")or die(mysql_error()); print_r($result); I get "Resource id #4", any idea? After I added while($row=mysql_fetch_assoc($result)) { print_r($row); } I just got [] What's wrong? ...

PHP: Variable in a function name

I want to trigger a function based on a variable. function sound_dog() { return 'woof'; } function sound_cow() { return 'moo'; } $animal = 'cow'; print sound_{$animal}(); * The * line is the line that's not correct. I've done this before, but I can't find it. I'm aware of the potential security problems, etc. Anyone? Many thanks. ...