php

KO3/Kohana3: How do we escape quotes (double and single) before saving to db with ORM using values()?

Hello everyone! I allow users to submit a question, and they should be able to have single quotes in their title. Currently, if a title contains a single quote, it will submit properly. $question->values($post_data); $question->save(); Any ideas on how I can set Kohana to escape that single quote / escape my information automatically? ...

How do I select a cell with multiple values in one column?

I have an MYSQL table with a large product list. In this product list table there are categories, a name, description, text, etc. I want to add a modifier for the industries that it can be used in (e.g. hospitals, schools, events, sport events, etc.) I'm running this query through PHP/MYSQL right now: public function GetIndustrySerie...

MySQL dB of POI, drop down with varius radiuses, results ajaxed onto a google map??

I have a MySQL database of addresses (my custom points of interest - not Googles) and their associated Lat/Long. What would be the simplest way for a user to my site (their lat/long is also stored in their user profile) to be shown a: google map with their own lat/long as a starting (center) point default radius of 10 Miles all Points...

jQuery, Ajax and REDIRECT_QUERY_STRING

Hi, I've been attempting to refactor a fairly simple three or four page site to use a very lightweight MVC setup (probably overkill - but I thought I'd try it out for fun). The site uses an .htaccess file: RewriteEngine on RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME...

PHP And Regular Expression

I need to check if any strings follow the same format as these. Val-Pak *Client Referral* Gift Certificate It needs to be done in regular expression. I can't find how to include the * and -. Thanks ...

finding array index based on value

I'm trying to find the index based on the value stored within it. This would normally be easy, but the array I'm working with is highly nested. Each index 0,1,2 has fields f1,f2,f3 . I'm trying to find which index 0,1,2 has in its f2 field the value this stored in it. In this case, it's index 0. So that's the output I'm looking for. Is...

Getting pagename using PHP_SELF - dangers?

Hi guys. I'm thinking of using PHP_SELF to grab the name of the page the user is currently visiting. I'm well aware of the dangers of using PHP_SELF in places like form actions, though I'm not sure where it would hurt to use in hrefs? But that's beside the main question . . . anyway. Are there any dangers in using PHP_SELF to grab the ...

Finding reason for MySQL query not working

Okay. I have this code on my site: <?php session_start(); include "database.php"; include "bruger.php"; $bruger = new bruger(); if( $bruger->logget_ind() ){ $brugernavn = $_SESSION['brugernavn']; $bruger_slash = addslashes($brugernavn); $hnavnn = mysql_query(" SELECT hnavn FROM bruger WHERE brugernavn = '" . $bruger_slash . "'"...

How can I split a string at the first occurrence of "-" (minus sign) into two $vars with PHP?

How can I split a string at the first occurrence of - (minus sign) into two $vars with PHP? I have found how to split on every "-" but, not only on the first occurrence. example: this - is - line - of whatever - is - relevant $var1 = this $var2 = is - line - of whatever - is - relevant Note, also stripped the first "-" . Thanks in ...

PEAR Mail is so slow, my front end is timing out.

I've got a php script that sends a few emails and echoes a response back to my front end. The problem is that the email handling is so slow, the front end is timing out. Here are the broad strokes for the email implementation. The scenario kicks off when User A books an offer from User B. User A gets a confirmation email, User B gets a...

Replacing words with tag links in PHP

I have a text ($text) and an array of words ($tags). These words in the text should be replaced with links to other pages so they don't break the existing links in the text. In CakePHP there is a method in TextHelper for doing this but it is corrupted and it breaks the existing HTML links in the text. The method suppose to work like this...

How else can I check the user for a program?

Currently, my friend has a program that checks the users Windows CD-Key and then it goes through a one way encryption. He, then, adds that new generated number to the program for checking purposes and then he compiles it and then he sends it off to the client. Is there a better way to keep the program from being shared utilizing PHP som...

Cant Update MySQL database

I am trying to learn mysql and having some problem with updating/adding data to the table this is my code and after running this page when I go to phpmyadmin to see if the new data showed up, i dont see it there. <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(!$conn) { die("Could not connect"); } $dbname = "test"; mys...

PHP - Multi line random array.

Say we have an array like this with 1 being two values and 2 being two values and 3, etc $language = array ( "1"=>array ( "Hola", "Spanish" ), "2"=>array ( "Fáilte", "Irish" ), "3"=>array ( "Yasou", "Greek" ) ); How would I randomly select ONLY 1 of 3 arrays an...

Algorithm for Saving a User's Credentials into a Database over HTTP

Any comments/improvements on this process? User Table: id, username, password, salt Storing a New User Receive the username (plaintext) from $_POST Receive the password (sha512'd using javascript) http://pajhome.org.uk/crypt/md5/sha512.html from $_POST Generate a 128 character salt (alphanumeric with symbols) on the server and store ...

Help to understand magic_quotes_gpc()

i was learning this PHP code from a tutorial to upload files <form method="post" enctype="multipart/form-data"> <input name="userfile" type="file" id="userfile"> </form> <?php if (isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_nam...

What's a good PHP development enviroment under Windows?

I have programed PHP a few days and found that It's not easy to debug the code(which I mean the PHP code itself, and especially the Javascript code). I am using gvim as editor, firebug and the truthful alert as debugger. But I am not satisfied, I need some killer feature like setting breakpoints, step code etc. Are there any developmen...

simplexml path by index

I'm parsing simplexml and normally my simple xml would look like this $sig_size = (int)$xmlObject->sig->points; which returns 24 in this example <?xml version='1.0' standalone='yes'?> <photo id='470'> <artist>mg</artist> <lines> <points>22</points> <angle>-5</angle> <x>165</x> <align>...

JQuery Validation Bug or User error?

Site in question: http://tinyurl.com/23oar6z You can look at the source for the javascript on the JQuery or the main part here: // validate signup form on keyup and submit var validator = $("#Register").validate({ rules: { UserID: { required: true, minlength: 2, remote: { ...

jQuery Validation plugin addMethod

Hi guys, I'm trying to add a new method to jQuery validation plugin with the codes below. My goal is to check whether the email address has already existed in the database(MySQL). If it is, it will inform the user to register for another email address. Somehow, the result that always returns is "Email is already taken". These are the c...