php

How to retrieve data after the 1st occurence of a number/digit in a string in php.

Hi All, We have a query(mysql) which returns data in the following format of alphabets followed by digits followed by alphabets like -- text1 12.12 mg text2 Now the issue is , i need to write a script in php which gives all the data starting from the 1st digit.so the result should be something like 12.12 mg text2 I am not sure how t...

how to make multiple hosting accounts using the same copy of the php code

Hi, We have a web app built on codeigniter. We have a VPS, with different accounts on it. I was wondering how can we setup in a way that there will be only one copy of the php code for all accounts. each account will have a different domain name, and each account will have their own mysql database. Therefor: code sits on a folder on t...

while(list($key, $value) = each($array)) vs. foreach($array as $key => $value)?

Recently I experienced this weird problem: while(list($key, $value) = each($array)) was not listing all array values, where replacing it with... foreach($array as $key => $value) ...worked perfectly. And, I'm curious now.. what is the difference between those two? ...

Trying to get property of non-object

This script works great. I call it in top of my scripts. But if a user that is NOT banned enters the site they get: Notice: Trying to get property of non-object in index.php on line 20 The function: // Check if conecting user is banned. If ban has expired delete row. function check_bans() { // IP address $user_ip = $_SERVER['REMOTE_...

How to decode eval(stripslashes(gzinflate ...

Hello, I've decoded code in footer and header of template, but don't know how to do it in functions.php in wordpress template. Can you please decode this code: <?php print(stripslashes(gzinflate(base64_decode("VZBNS8QwEIbvC/0PcyikhbJ611rY9QPZxZOKSKCUyYSETZOSpB4U/7uztCLCHGbeZ767m+sO9Owx2+ABDeGpNzQoilX9VWwAoHStFE+7l9cd7t/swd0e3h+OUlwtUL...

How the Java equivalent to this preg_replace?

<?php $str = "word <a href=\"word\">word</word>word word"; $str = preg_replace("/word(?!([^<]+)?>)/i","repl",$str); echo $str; # repl <word word="word">repl</word> ?> source: http://pureform.wordpress.com/2008/01/04/matching-a-word-characters-outside-of-html-tags/ Unfortunality my project needs a semantic libs avaliabl...

PHP: session_cookie over subdomains?

Hey guys, I'm rather new to PHP and sessions. I've actually never worked with them before and I'm having quite a few problems working with them with AJAX over a subdomain. I'm on http://www.example.com/whatever and I'm setting the cookie with: session_set_cookie_params(0, '/', '.example.com'); session_start(); if(!isset($_SESSION['pass...

HTML span tag content and attribute preg_match regular expressions

Hello, Does anyone have a fix for the following; I'm taking the following string: <span id="tmpl_main_lblWord" class="randomWord">kid</span> and using the following preg_match / regex rule; preg_match("'/(<span id=.* class=.*>)(.*)(<\/span>)/'si", $buffer, $match); But its returning with an empty array any ideas? ...

What is the correct way to get values from the query string in Kohana 3

Just curious as to what is the 'Kohana' way of getting variables from the query string? The best that I could come up with is parsing the $_GET var with the Arr class. Anybody have a better way to do this? // foo?a=1&b=2 function action_welcome() { echo('a = '.Arr::get($_GET, 'a', '0')); echo('b = '.Arr::get($_GET, 'b', '0'));...

How to implement MD5 hashing in a user registration and login system?

I am using PHP and Mysql. I want to know how to send password hashed using MD5 and want to check against it when the user tries to log in. I tried it, but it's not working properly. If anyone knows how to do it, please provide me the code. ...

What's the best way to remove Registered, Trademark, and Copyright symbols from a string?

What's the best way to remove symbols, like the Registered, Trademark, and Copyright symbols from a string? For instance I'd like to strip the ® out of the following: $string = 'Can't Touch This®'; ...

What are compressor modules? Why are they important? How to use it?

I have no idea of what compressor modules like gzip are, I have never used it so far, but it sounds like it can improve the site performance a lot, so I want to know What are compressor modules? Why are they important? and, How to use it? In terms for PHP. ...

How to process decimals properly in PHP?

I want to store prices like this in the mysql database: 1000 instead of like this: 10.00 And when I echo the output I want the number to be displayed with decimals and commas in the proper places. So if this is in the database: 100000 it should display as: 1,000.00 if this is in the database: 1000000 it should show as 10,000.0...

php time_sleep_until() and "Mysql server has gone away"

hello! i have script which must execute after every n minutes. n minutes is dynamic so that i could not set a cron job to call the script (at a specific time). so what i did was i stored the time after every n minutes in an array so that when the script is executed, it will first check whether the current time is in the array. if it i...

Javascript Span as PHP Variable

As the title suggests, I have a span that is automatically generated by SimpleCart (Javascript Cart) - I want to use that span with a different checkout gateway then they support. Therefore, I need to take some of their tags and "echo" them into PHP variables. For example: <input type="hidden" name="fltAmount" value="###"> <span clas...

PHP MySQL Database Connection

Is it necessary to explicitly close a DB connection after executing a query (and other DB operation)? ...

Symfony 1.4 - Updating hidden value when form is updated

Hey I am trying to modify the default value of a form field every time the form is updated. I have tried to edit the $form->bind in my processForm (..) but I am unsure how to do so. Is it possible to get some example code or any approaches to do? The field name is 'processed' and I am trying to set the value to 'false' - Using Symfony...

Codeigniter Validation Rules Help

I want to validate landphone and mobile phone fields in my CI application. I have set validation rules as integer but user cannot enter values seperated by " - " . If i use "text" type, user can enter alphabets also.....how do i solve this issue....i want user to enter "-" and "+" values in the fields and not any other texts Code: $th...

PHP: mycrypt key?

please don't mind me asking this but I'm new to php and I need to encrypt and decrypt a password. I want to send the password over a URL so I heard it's the safest way to use mycrypt. I don't get the thing with the KEY in the mycrypt function? Shouldn't that be as secret as the password itself. e.g. I'm using this function from the PHP ...

function to generate 26 (A-Z) * 26 (A-Z) * 26 (A-Z)

Hello, I'd like to create a function which will generate a 3 char key string after each loop. There are 26 chars in the alphabet and I'd like to generate totally unique 3 char keys (A-Z). The output would be 17,576 unique 3 char keys (A-Z) - not case sensitive. Can anyone give me an idea on how to create a more elegant function witho...