php

Use single or mulitple mysql users for SaaS PHP/mysql application with multi-tenant architecture

We are building a multiuser app that has one database per customer. All customer database structures are identical. Right now we are generating a new mysql user (per client) that only has privileges to work on its own database. e.g. mysql user1 has rights on dbase1.* (database1.alltables), mysql user2 has rights on dbase2.*. We are no...

Are there any recommended tools for beautifying PHP/HTML?

Does anyone know of a good tool for cleaning up/formatting PHP files? I'd need something that can handle HTML with < ?php ?> tags, as well as pure PHP files. Ideally, I'd like a Maven mojo, since the rest of my code is being generated by Maven already. ...

MySQL insert to multiple tables (relational)

tbl_product Name | Creator | UID | Salerank tbl_price Supplier | Price | UID I want to insert a product and then insert multiple prices into a seperate table. How is it possible to ensure that both tables had the same UID ideally an auto increment field? I will be using PHP alongside MySQL. Thanks, J ...

Regex to match "{number}"

I need to replace "{Z}" with "test(Z)" where Z is always an unsigned integer using PHP and regular expressions (unless there's a faster way?). $code='{45} == {2}->val() - {5}->val()'; // apply regex to $code echo $code; // writes: test(45) == test(2)->val() - test(5)->val() The tricky part is that it needs to be done in the best manne...

Google Maps v2 div inside or over map

I just need put one div (or more) inside or over map, something like a menu inside the map area, I need when i load my map this div is there... css can't do it right? that div contains php code... ...

Best way to include view within view in Codeigniter template using Dwoo?

I am using Codeigniter 1.7.2 and Phil Sturgeon's wonderful Dwoo wrapper which allows me to use the Dwoo template library in Codeigniter - http://philsturgeon.co.uk/code/codeigniter-dwoo I have a small question regarding the inclusion of other view template files within my template files. Say for example I have a dashboard.php file and I...

SimplePie XML document invalid

I am trying to parse a XML using SimplePie. SimplePie wouldn't even recognize this as RSS if I didn't turn set force_feed to TRUE. The error message shown by SimplePie: This XML document is invalid, likely due to invalid characters. XML error: Not well-formed (invalid token) at line 1, column 1 The first 2 lines of the XML do...

Remove line from end of file with PHP

How would I remove a line from the end of a string with PHP? Thanks. ...

How to implement a chatroom?

I am very wondering if there are any popular apis/frameworks currently available to do this? I am familiar with PHP and Javascript. So I am wondering how would one design a chat room? How does the server push the data to the individual connected clients? I would like to build the server and the client side all on my own as a practice....

Combining two input arrays into a single array to input into a database with PHP

I have a jQuery function that allows a user to create a list of links. By clicking on an "add row" link they create as many of these blocks (shown below) as they like which they can type the information into. <div class="links_row"> <input type="text" name="link_name[]"> <input type="text" name="link_url[]"> </div> I am post...

Delete first instance of string with PHP

How do I delete the first instance of a substring in another string with PHP? Thanks. ...

Simple PHP script help, if/else/timestamps/ less than / bit-shift

I am trying to make a timestamp function that checks which displays a time if it has been less than 24 hours and a date if it has been more. If anybody knows of a prebuilt way to do this please let me know. Anyways, I've started with this simple php which is suppose to return a number less than 86400 if $temprow1 or 2 are less than 8640...

When converting a mysql time in php I always get 16:00:20, regardless of the mysql time.

I am having trouble with converting time, when I use the date() function on a mysql timestamp, it only returns 16:00. Am I using the date() function wrong? PHP: date_default_timezone_set('America/Los_Angeles'); $date = date('H:i:s A'); echo "System: $date <br />"; $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $q...

"Call to undefined method" - but I know it exists.

This line of code: echo "<strong> {$this->author->last} {$this->date->shortYear()}</strong> ..."; gives me this error: Fatal error: Call to undefined method Date::shortYear() in /f5/debate/public/libs/Card.php on line 22 Even though in Date.php (which is included in Card.php): class Date { public $day; public $month; ...

How do I create a file upload progress bar in PHP?

Hi In my PHP web site, i want to create a file uploading progress bar. I have used many code, but it's not working. My PHP version is 5.2.8 and sever is in Linux. Please give me a solution. ...

Reading remote file size using filesize

Hi, I read the manual that filesize() is able to calculate file size from remote file. However, when I try to do that with snippet below. I got error PHP Warning: filesize(): stat failed for http://someserver/free_wallpaper/jpg/0000122_480_320.jpg in /tmp/test.php on line 5 Here's my snippet: $file = "http://someserver/free_wallpaper...

JavaScript to trigger PHP

Is it possible to have an input text box such that when a person types something and presses submit or enter, I can trigger PHP to submit that data to a database without leaving the page (hence the JavaScript)? ...

Error handling in the model, or in the controller?

Hi! I asked around on various IRC channels but was unable to get an answer with a definitive explanation behind it. Should errors (pertaining to the model, such as transaction failures) be handled in the model, or in the controller? Thanks in advance for any help. EDIT Well, the confusing thing is that my code (in the model) looks so...

Encrypting a value using MySQL's AES_ECRYPT function, then passing it in a URL string, using PHP

Hi There, I need to encrypt a string using MySQL's AES_ENCRYPT function, then attach that encrypted string to the end of a URL, such that it can then be decrypted and used by a PHP script on the other end. Basically, I am encrypting the string (using MySQL's AES_ENCRYPT), I am then using PHP's rawurlencode() function to make it "URL sa...

How to send e-mail to multiple recipients from database query (PHP)

I'm trying to send an e-mail to multiple e-mail address in my database. Here is my current code. It is only working when I specify a single e-mail address, however, I need to have them query my database and send the e-mail to each e-mail address. Where am I going wrong here? function sendmail($cat, $user) { require_once "Mail.php"; ...