Page 1 of 1
Php error need help
Posted: Wed Feb 17, 2010 10:27 pm
by sjakalen
I have 2 more errors since update from php 5.2 to 5.3 and I hope someone can help me
The error is
1.
PHP Deprecated: Function ereg() is deprecated in products.php on line 35
2.
PHP Deprecated: Function ereg() is deprecated in cart_add.php on line 23
1 code
Code: Select all
foreach ($_GET as $key => $value) {
if ( (ereg('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) ) {
$id = $key;
}
2 Code
Code: Select all
foreach ( $_GET as $key => $value ) {
if ( (is_numeric($key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) ) {
$id = $key;}
Re: Php error need help
Posted: Wed Feb 17, 2010 10:49 pm
by Weiry
You should try using
preg_match()
Re: Php error need help
Posted: Thu Feb 18, 2010 4:26 am
by sjakalen
Like this?
Code: Select all
if ( (preg_match()('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || preg_match()('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) ) {
I don't think it works, did I do something wrong?
Re: Php error need help
Posted: Thu Feb 18, 2010 4:37 am
by aravona
Code: Select all
preg_match('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || preg_match('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName())
I think you had too many brackets before

Re: Php error need help
Posted: Thu Feb 18, 2010 4:38 am
by dejvos
Pleas look for preg_match() in PHP documentation
http://cz.php.net/manual/en/function.preg-match.php
and the depracated is not a quite an error it means that:
http://en.wikipedia.org/wiki/Deprecation
Re: Php error need help
Posted: Fri Feb 19, 2010 6:36 am
by sjakalen
That don't work it give me another error on the same line any Idea?
PHP Parse error: syntax error, unexpected T_STRING, expecting '(' in /customers/indoexport.eu/indoexport.eu/httpd.www/includes/content/products/products.php on line 35
Code: Select all
if ( (preg_match('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || preg_match('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) {
Re: Php error need help
Posted: Fri Feb 19, 2010 7:11 am
by aravona
It means you have a ( in the wrong place or there is one missing. Go through and check each open bracket has a closing bracket to partner with. The error pretty much tells you that.
preg_match() doesnt need to sit inside brackets like you have it. Did you read the manual linked now for the third time?
http://cz.php.net/manual/en/function.preg-match.php
Code: Select all
if ( preg_match('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) || preg_match('^[a-zA-Z0-9 -_]*$', $key) && ($key != $osC_Session->getName())
Try that. The IF opens around the preg_match, the preg_match contains what it needs to contain - then closes, new preg_match with its own information, then the bit with the get name, closes the IF.
Should work. Counting brackets is annoying but you
really can double check that yourself.
Re: Php error need help
Posted: Fri Feb 19, 2010 7:45 am
by sjakalen
I did reed the manuel but I am no expert, and I did not understant it very wel, I'm sorry
I stil can't make it work

Re: Php error need help
Posted: Sat Feb 20, 2010 1:21 am
by sjakalen
I did get some response doing like this
Code: Select all
if (preg_match('^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$', $key) ||
preg_match('^[a-zA-Z0-9 -_]*$', $key) && ($key != $osC_Session->getName)) {
But my product was not found and thise error was posted
PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: No ending delimiter '^' found in products.php on line 36
PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: No ending delimiter '^' found in products.php on line 35
I don't get it

Re: Php error need help
Posted: Sat Feb 20, 2010 1:37 am
by flying_circus
Code: Select all
if (preg_match('/^[0-9]+(#?([0-9]+:?[0-9]+)+(;?([0-9]+:?[0-9]+)+)*)*$/', $key) ||
preg_match('/^[a-zA-Z0-9 -_]*$/', $key) && ($key != $osC_Session->getName)) {
Re: Php error need help
Posted: Sat Feb 20, 2010 1:41 am
by sjakalen
Hi FC
Working but post an error
PHP Notice: Undefined property: osC_Session_database::$getName in products.php on line 36
What is that about?
Re: Php error need help
Posted: Sat Feb 20, 2010 1:44 am
by sjakalen
I got it () after getname

Now it works
Thanks
Re: Php error need help
Posted: Sat Feb 20, 2010 1:45 am
by sjakalen
Can you help with my last error
Code: Select all
foreach ( $_GET as $key => $value ) {
3. if ( (is_numeric($key) || ereg('^[a-zA-Z0-9 -_]*$', $key)) && ($key != $osC_Session->getName()) ) {
4. $id = $key;}
Re: Php error need help
Posted: Sat Feb 20, 2010 1:53 am
by sjakalen
I got that to,,
Im getting good at this
Code: Select all
if ( (is_numeric($key) || preg_match('/^[a-zA-Z0-9 -_]*$/', $key)) && ($key != $osC_Session->getName()) ) {
I thinkit is ok