Gettext works sometimes - php

I'm working on a project and I need to user translation for it. So I decided to use gettext in php but it's working sometimes.
So I have a folder named lng and in this on I have a php file who call my lang file to translate my page.
Here is the code :
<?php
if(isset($_GET['lang']) != '')
{
setcookie('lang',$_GET['lang'], time() + 365*24*3600, null, null, false, true);
$_SESSION['lang'] = $_GET['lang'];
$language = $_GET['lang'];
}
else if(isset($_SESSION['lang']) != '' )
{
$language = $_SESSION['lang'];
}
else if(isset($_COOKIE['lang']) != '')
{
$_SESSION['lang'] = $_COOKIE['lang'];
$language = $_SESSION['lang'];
}else{
$language = 'fr';
}
putenv("LANG=$language");
setlocale(LC_MESSAGES, $language);
$domain = 'trad';
bindtextdomain($domain, 'locale/');
textdomain($domain);
?>
So I can check my $_SESSION and $_COOKIE, no problem he give me 'en' or 'fr' but he doesn't translate my file and I don't know why.
For the folder in lng it's : locale/en/LC_MESSAGES/trad.po (or .mo).
I try with LC_ALL and LC_MESSAGES but that doesn't change the result.
Did I miss something or made a wrong stuff?
Thanks a lot!
J.

I've got the same problem. Restart Apache Service solved it for me

Aren't you using windows? If so, you must use windows locale names. Here is part of my class working for me on linux and also on windows (it simply has more options of locale names):
...
private function setLocaleByLang($lang)
{
$map = array(
'cs' => array('cs_CZ.UTF-8', 'cs_CZ', 'cs', 'czech'),
'en' => array('en_US.UTF-8', 'en_US', 'en', 'english'),
'de' => array('de_DE.UTF-8', 'de_DE', 'de', 'german'),
'pl' => array('pl_PL.UTF-8', 'pl_PL', 'pl', 'polish'),
'sk' => array('sk_SK.UTF-8', 'sk_SK', 'sk', 'slovak')
);
$locale = key_exists($lang, $map) ? $map[$lang] : $lang;
setlocale(LC_ALL, $locale);
putenv('LC_ALL=' . $lang); // for windows and gettext
}
...

I'm running into the same error. My case is a bit different, and I'm starting to think it has something to do with threading, despite it happens since I changed my code.
I have a language bar:
<?php
include_once (dirname(__FILE__) . "/resources/config.php");
?>
<div id='language_bar'>
<a style="margin-left:50px" href="./index.php?locale=es_ES">
<img src='<?php echo $config['paths']['images']['lang']?>/es_ES.gif'/>
</a>
<a href="./index.php?locale=en_UK">
<img src='<?php echo $config['paths']['images']['lang']?>/en_UK.gif'/>
</a>
<a href="./index.php?locale=de_DE">
<img src='<?php echo $config['paths']['images']['lang']?>/de_DE.gif'/>
</a>
</div>
And a config file with:
if (isset($_GET['locale'])) {
$locale = $_GET['locale'];
setcookie('locale', $locale, time() + 60 * 60 * 24 * 30);
} else {
if(isset($_COOKIE['locale'])) {
error_log('En _COOKIE');
$locale = $_COOKIE['locale'];
}
else {
$locale = $config['localization']['default_locale'];
setcookie('locale', $locale, time() + 60 * 60 * 24 * 30);
}
}
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
error_log('setlocale->'.setlocale(LC_ALL, "0")." Env ->". getenv("LC_ALL"));
error_log(_("Submit"));
My main page has some divs interacting via jQuery, and reloading in cascade. Sometimes, some of them (randomly) give a default string value.
by default, it is in spanish (es_ES), and after a few clicks forcing div refreshes, some string is printed in english (en_UK original string). And what is more. If I switch to german (de_DE), after a first refresh where I get every string in german, gettext starts to reurn strings in spanish, and after a while, in english.
Note that I added debug lines to php log. They are really interesting:
When things go right:
[Thu May 31 00:28:51 2012] [error] [client ::1] setlocale->es_ES Env ->es_ES
[Thu May 31 00:28:51 2012] [error] [client ::1] Aplicar, referer: xxxxxxxx/index.php
When do not:
[Thu May 31 00:29:45 2012] [error] [client ::1] setlocale->es_ES Env ->es_ES, referer: xxxxxxxxx/index.php
[Thu May 31 00:29:45 2012] [error] [client ::1] Submit, referer: xxxxxxxx/index.php
So I guess it's _() function failing (I'm always using the alias). Just in case, I looped for 10.000 times over the function, and it gave or 10.000 hits or 10.000 mistakes while translating, so it fails for a whole http request, or doesn't.
My apologies for writing so much, but I would really appreciate some help pointing me in the right direction. (This error occurs not just # my localhost, but also at my online test server)
¿might have anything to do with the fact that I'm setting the locale for every connection?
My online "playground" is:
Linux server8.nixiweb.com 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64
My server:
Linux filete 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64
PHP Version 5.3.10-1ubuntu3.1
Note that both are 64bits

I had the same problem. Sometimes the strings were translated and sometimes don't. I have 3 servers for this application and 5 developers' machines, all with the same problem.
I solve it by removing:
bindtextdomain("domain", "/locale");
And linking the .mo file directly on the gettext default folder:
sudo ln -sf /myproject/locale/en/LC_MESSAGES/domain.mo /usr/share/locale/en/LC_MESSAGES/domain.mo
I am using Ubuntu 14.04.

Related

Laravel 8 error vendor/symfony/polyfill-mbstring/Mbstring.php

i want to ask about the problem i'm having. I'm using 2 desktops i.e. ubuntu and mint, when I run my code on ubuntu it runs smoothly. but if i run on mint desktop i have an error that says "Symfony\Component\ErrorHandler\Error\FatalError
Maximum execution time of 60 seconds exceeded"
and i get this log on my terminal
Starting Laravel development server: http://127.0.0.1:8000
[Tue Nov 9 16:18:53 2021] PHP 8.0.12 Development Server (http://127.0.0.1:8000) started
[Tue Nov 9 16:18:55 2021] 127.0.0.1:38908 Accepted
[Tue Nov 9 16:18:55 2021] 127.0.0.1:38910 Accepted
[Tue Nov 9 16:20:22 2021] PHP Fatal error: Maximum execution time of 60 seconds exceeded in /home/aditya/Documents/Laravel/eyrin/vendor/symfony/polyfill-mbstring/Mbstring.php on line 632
[Tue Nov 9 16:20:23 2021] 127.0.0.1:38908 Closing
[Tue Nov 9 16:20:23 2021] 127.0.0.1:38910 Closed without sending a request; it was probably just an unused speculative preconnection
[Tue Nov 9 16:20:23 2021] 127.0.0.1:38910 Closing
and this is code on controller
$store = Store::where('user_id',Helper::getSession('user_id'))->first();
$match_report = [];
$top_weekly_product = [];
$compressed_date = [];
$uncompressed_date = Report::where('store_id',$store->id)->whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->select('created_at')->distinct()->get();
foreach ($uncompressed_date as $item) {
if(!in_array(Carbon::parse($item['created_at'])->format('d/m/Y'),$match_report)){
$match_report[] = Carbon::parse($item['created_at'])->format('d/m/Y');
$compressed_date[] = $item;
}
}
$match_report = [];
$compressed_weekly_product = [];
$uncompressed_weekly_product = Report::where('store_id',$store->id)->whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->get()->map(function($report){
return [
'product_name'=>$report->product_name,
'product_variant'=>$report->product_variant,
'product_sku'=>$report->product_sku,
'weekly_amount'=>sizeof(Report::where(['store_id'=>$report->store_id, 'product_sku'=>$report->product_sku])->whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->get())
];
});
foreach ($uncompressed_weekly_product as $item) {
if(!in_array($item['product_sku'],$match_report)){
$match_report[] = $item['product_sku'];
$compressed_weekly_product[] = $item;
}
}
foreach ($compressed_weekly_product as $key => $item) {
$rows = [];
foreach ($compressed_date as $obj) {
$rows[] = sizeof(Report::where(['store_id'=>$store->id, 'product_sku'=>$item['product_sku']])->whereDate('created_at', Carbon::parse($obj['created_at']))->get());
}
$compressed_weekly_product[$key]['daily_amount'] = $rows;
}
foreach ($compressed_date as $key => $item) {
$compressed_date[$key]['formated'] = Carbon::parse($item->created_at)->format('m/d/Y');
}
$match_report = [];
usort($compressed_weekly_product, function($a, $b) {
return $a['weekly_amount'] > $b['weekly_amount'] ? -1 : 1;
});
foreach ($compressed_weekly_product as $item) {
if(sizeof($top_weekly_product) < 3){
$top_weekly_product[] = $item;
}
}
//testing
$growth_percentage = 1.8;
return view('panel.outlet.dashboard.index', [
'is_dashboard'=>true,
'total_customer'=>sizeof(Customer::where('store_id',$store->id)->get()),
'total_revenue'=>Order::where('store_id',$store->id)->whereIn('status',['2','3','-'])->sum('total_amount'),
'total_order'=>sizeof(Order::where('store_id',$store->id)->get()),
'total_sales'=>sizeof(Order::where('store_id',$store->id)->whereIn('status',['2','3','-'])->get()),
'total_product'=>sizeof(Product::where('store_id',$store->id)->get()),
'total_sales_income'=>Order::where('store_id',$store->id)->whereIn('status',['2','3','-'])->sum('total_amount'),
'growth_percentage'=>round($growth_percentage,2),
'lastest_order'=>Order::where(['store_id'=>$store->id,'type'=>'app'])->orderBy('id','DESC')->limit(10)->get(),
'report_date'=>$compressed_date,
'top_weekly_product'=>$top_weekly_product,
'weekly_product'=>$compressed_weekly_product,
'weekly_report'=>DailyReport::where('store_id',$store->id)->whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->get()]);
}
can anyone help me with this problem? i had a similar experience when i tried to truncrate a string in my blade view. does it have something to do with the configuration in my php.ini?
thankss i hope get solution for this problem...
This error appends when the max_execution_time of your PHP is reached. From the look of your error, it is probably set to 60 seconds.
You can increase this limit directly into your php.ini file (see with the command php --ini where it is located on your machine) or try to optimize your code.
If you don't want to edit the max_execution_time permanently, you can also add the instruction:
set_time_limit($seconds);
at the beginning of your script. I would not recommend this solution.
You can set it in the php.ini file in the max_execution_time variable, the default is 60 seconds, you can change it according to your needs
Symfony\Component\ErrorHandler\Error\FatalError
Maximum execution time of 60 seconds exceeded
There was a problem with the route. check your web.php
Route::get('feedback', 'App\Http\Controllers\FeedBackController#index')->name('feedback.index');
changed to
Route::get('cfeedback', 'App\Http\Controllers\FeedBackController#index')->name('feedback.index');
added only c in before feedback
I was having the same issue.
Running php via software collection the mbstring package was not installed.
# dnf install -y php73-php-mbstring
# systemctl restart php73-php-fpm
After installing packages and restarting service it was working well.
In your php.ini file, Uncomment extension=mbstring and you will see the error goes away.

TYPO3 PHP Update to 7.0 | the logs say "Switch statements may only contain one default clause"

I want to update PHP from 5.6 to 7.0 but I get a 500 HTML Error and in the logs it says:
[Mon Oct 22 09:42:14 2018] [-:error] [pid 12784] [client 5.158.158.123] [host www.mydomain.de] PHP Fatal error: Switch statements may only contain one default clause in /is/htdocs/wp12731216_QEO0DONMD6/www/typo3conf/ext/dam/lib/class.tx_dam_db.php on line 547
So I looked into the file and found as it says a dublicate default: statement:
if ($appendType = $TCA['tx_dam']['columns'][$field]['config']['appendType']) {
$appended = true;
switch($appendType) {
case 'space':
$rowUpdate[$field] = trim($row[$field].' '.$value);
break;
case 'newline':
$rowUpdate[$field] = $row[$field].($row[$field]?"\n":'').$value;
break;
case 'comma':
$rowUpdate[$field] = $row[$field].($row[$field]?', ':'').$value;
break;
case 'charDef':
default:
list($type, $appendChar) = explode(':', $appendType);
$rowUpdate[$field] = $appendChar.$value;
break;
default:
$appended = false;
break;
}
}
So my Question is, is there a solution? Can I just edit this file and remove the last default statement? Or should I update to a different PHP Version?
So I found the solution myself after a while...
I had to update the Extension where the file with the error comes from.

[RIAK-PHP-CLIENT]: Fetch and display JSON text data on localhost from Riak

I have successfully gotten a connection between my riak database and localhost by using the official Basho riak-php-client:
https://github.com/basho/riak-php-client
In my Riak database, I have a lot of keys stored with JSON data. Is there any easy and effective way of displaying the text data on the localhost? So far, I have been able to display simple other values using this code:
<?php
require_once('src/Basho/Riak/Riak.php');
require_once('src/Basho/Riak/Bucket.php');
require_once('src/Basho/Riak/Exception.php');
require_once('src/Basho/Riak/Link.php');
require_once('src/Basho/Riak/MapReduce.php');
require_once('src/Basho/Riak/Object.php');
require_once('src/Basho/Riak/StringIO.php');
require_once('src/Basho/Riak/Utils.php');
require_once('src/Basho/Riak/Link/Phase.php');
require_once('src/Basho/Riak/MapReduce/Phase.php');
$client = new Basho\Riak\Riak('172.31.42.72', 10018);
$myBucket = $client->bucket('test');
$myBucket1 = $client->bucket('world');
$val1 = 1;
$obj1 = $myBucket-> newObject('one', $val1);
$obj1->store();
$val2 = 'two';
$obj2 = $myBucket->newObject('two', $val2);
$obj2->store();
$val3 = array('myValue' => 3);
$obj3 = $myBucket->newObject('three', $val3);
$obj3->store();
$fetched1 = $myBucket->get('one');
$fetched2 = $myBucket->get('two');
$fetched3 = $myBucket->get('three');
$fetched4 = $myBucket1->get('542660947589230592');
assert($val1 == $fetched1->getData());
assert($val2 == $fetched2->getData());
assert($val3 == $fetched3->getData());
$obj = json_decode(fetched4);
print $obj->{'<<"text">>'};
?>
In this code I have also tried to display the JSON data which is in the variable $fetched4, and queried from the bucket 'world', but when I try and display it with these two lines of code:
$obj = json_decode(fetched4);
print $obj->{'<<"text">>'};
Nothing is displayed. Any ideas?
EDIT
Here are the apache2 error logs although I am not entierly sure if they're fully up-to-date:
[Wed Dec 10 14:05:20.894220 2014] [:error] [pid 4610] [client
129.16.723.16:44285] PHP Notice: Use of undefined constant fetched4 - assumed 'fetched4' in /var/www/html/index.php on line 52
[14:05:20.894240 2014] [:error] [pid 4610] [client 129.16.723.16:44285]
PHP Notice: Trying to get property of non-object in
/var/www/html/index.php on line 53[Wed Dec 10
Try...
$obj = json_decode($fetched4);
Unless it was a typo in entering your example here, you're missing the $ on $fetched4.
The log entry PHP Notice: Use of undefined constant fetched4 - assumed 'fetched4' points to it being a real problem and not just something you've done here though.

php zend framework http client error

I am trying to write a piece of php code with zend framework. I`m using zend_http_client.The code works randomly!I mean , It works fine sometimes and sometimes get an empty page and this error from Apache error log :
[Mon May 27 16:46:37 2013] [error] [client 4.4.4.4] PHP Warning: require_once(/var/www/my.somesite.com/library/Zend/Http/Client/Adapter/Exception.php): failed to open stream: Too many open files in /var/www/my.somesite.com/library/Zend/Http/Client/Adapter/Socket.php on line 222
[Mon May 27 16:46:37 2013] [error] [client 4.4.4.4] PHP Fatal error: require_once(): Failed opening required 'Zend/Http/Client/Adapter/Exception.php' (include_path='/var/www/my.somesite.com/application/../library:../application/models:.:/usr/share/php:/usr/share/pear') in /var/www/my.somesite.com/library/Zend/Http/Client/Adapter/Socket.php on line 222
[Mon May 27 16:46:37 2013] [error] [client 4.4.4.4] PHP Fatal error: Undefined class constant 'PRIMARY_TYPE_NUM' in /var/www/my.somesite.com/library/Zend/Session/SaveHandler/DbTable.php on line 522
php code sth like this :
public function Request($server_method, $params_arr) {
$httpClient = new Zend_Http_Client;
$httpClient->setConfig(array('timeout' => '900'));
$client = new Zend_XmlRpc_Client ( Zend_Registry::getInstance ()->config->ibs->xmlrpc_url ,$httpClient);
$request = new Zend_XmlRpc_Request ( );
$response = new Zend_XmlRpc_Response ( );
$request->setMethod ( $server_method );
$request->setParams ( array ($params_arr ) );
$client->doRequest ( $request, $response );
if ($response->isFault ()) {
$fault = $response->getFault ();
//echo '<pre>' . $fault->getCode () . '' . $fault->getMessage () . '</pre>';
$this->response = array (FALSE, $fault->getMessage () );
return array (FALSE, $fault->getMessage () );
}
//return $response;
$this->response = array (TRUE, $response->getReturnValue () );
return array (TRUE, $response->getReturnValue () );
//var_dump($response->getReturnValue());
}
Where is the problem ?
The problem may be not related to your method itself.
You are opening many files and not closing them (a socket count as a file open too). The socket adapter itself has a configuration called persistent, set false to prevent TCP reuse.
Try to check if your http client is properly destroyed at end of use and is not refered in another place of your code (that prevents garbage collector cleaning).
More info:
Check the limits with ulimit -aH (max limit for number of open files)
There some numbers too in /etc/security/limits.conf
soft nofile 1024 <- Soft limit
hard nofile 65535 <- Hard limit
You could increase ulimit by ulimit -n 65535 and echo 65535 > /proc/sys/fs/file-max to set a higher value, but this is strongly discouraged.
To set this permamently, in /etc/sysctl.conf set fs.file-max=65535

Could someone help me understand why this MySQL update code isn't working php 5

Here is the code. It seems to be having an issue in PHP 5. It works well in PHP 4.4.9.
if($_REQUEST['action']== "Update"){
$curDate = date("Y-m-d");
$image =$_FILES['vImage']["name"];
$uploadedfile = $_FILES['vImage']['tmp_name'];
$sql="UPDATE businessad
SET iBUserID= '$_REQUEST[iBUserID]',
iCategoryID= '$_REQUEST[iBCategoryID]',
vAdTitle= '$_REQUEST[vAdTitle]',
tAdText= '$_REQUEST[tAdText]',
vAdImage= '$vAdImage',
vAdURL= '$_REQUEST[vAdURL]',
dStartDate= '$_REQUEST[dStartDate]',
dEndDate= '$_REQUEST[dEndDate]',
vAddress1= '$_REQUEST[vAddress1]',
vAddress2= '$_REQUEST[vAddress2]',
vCity= '$_REQUEST[vCity]',
vState= '$_REQUEST[vState]',
vZipCode= '$_REQUEST[vZipCode]',
vPhone= '$_REQUEST[vPhone]',
vEmail= '$_REQUEST[vEmail]',
eStatus='$_REQUEST[eStatus]'
WHERE iBusAdID='".$_REQUEST['iBusAdID']."'";
$db_sql=$obj->sql_query($sql);
if($db_sql)
{
$msg=MSG_UPDATE;
header("Location:businessadview.php?var_msg=$msg");
exit;
}
else
{
$msg=MSG_UPDATE_ERROR;
header("Location:businessadview.php?var_msg=$msg");
exit;
That code doesn't update to the MySQL table, and I'm not sure why.
What precedes the above code is a form that looks like this
<form name="frmadd" method="post" action="businessadadd_a.php" enctype="multipart/form-data">
<input type="hidden" name="action" value="<?=$action;?>">
<input type="hidden" name="iBusAdID" value=<?=$iBusAdID;?>>
I check my server error logs and found out this. It mentions some errors in the globals.php, which is a part of the include call up. I'll include the include code too.
Here is the include code
<?php
#session_start();
#ob_start();
include_once("./lib/db_config.php");
include_once("./lib/myclass.php");
include_once("./lib/globals.php");
if(!isset($obj)){
$obj = new myclass($SERVER,$DBASE,$USERNAME,$PASSWORD);
}
include_once("./lib/generalsettings.php");
include_once("./function/general.php");
include_once("./lib/messages.php");
getGeneralVar();
?>
Here is the globals.php code that the server error logs have an issue with
<?php
$glob=array("SERVER");
if(isset($GPC_vars))
{ foreach($GPC_vars as $var)
{ foreach(array("GET","POST","COOKIE") as $avar)
if(isset($GLOBALS["HTTP_".$avar."_VARS"][$var]))
{ $$var=$GLOBALS["HTTP_".$avar."_VARS"][$var];
}
}
}
else
{ $glob=array_merge(array("GET","POST","COOKIE"),$glob);
}
foreach($glob as $avar)
{ $arr=$GLOBALS["HTTP_".$avar."_VARS"];
foreach($arr as $var => $res)
$$var=$res;
}
foreach ($HTTP_POST_FILES as $name => $value) {
$$name = $value["tmp_name"];
foreach($value as $k=>$v) {
$varname_ = $name."_".$k;
$$varname_ = $v;
}
}
reset($HTTP_POST_FILES);
?>
Here is what the error logs say
[Mon Mar 14 13:08:55 2011] [error] [client -] File does not exist: /public_html/favicon.ico
[Mon Mar 14 13:08:54 2011] [error] [client -] PHP Warning: reset() [function.reset]: Passed variable is not an array or object in /public_html/lib/globals.php on line 30, referer: xxx.com/admin/businessadadd.php?iBusAdID=4&action=Update
[Mon Mar 14 13:08:54 2011] [error] [client -] PHP Warning: Invalid argument supplied for foreach() in .../public_html/lib/globals.php on line 23, referer: xxx.com/admin/businessadadd.php?iBusAdID=4&action=Update
[Mon Mar 14 13:08:54 2011] [error] [client -] PHP Warning: Invalid argument supplied for foreach() in .../public_html/lib/globals.php on line 19, referer: xxx.com/admin/businessadadd.php?iBusAdID=4&action=Update
[Mon Mar 14 13:08:54 2011] [error] [client -] PHP Warning: Invalid argument supplied for foreach() in .../public_html/lib/globals.php on line 19, referer: xxx.com/admin/businessadadd.php?iBusAdID=4&action=Update
[Mon Mar 14 13:08:54 2011] [error] [client -] PHP Warning: Invalid argument supplied for foreach() in .../public_html/lib/globals.php on line 19, referer: xxx.com/admin/businessadadd.php?iBusAdID=4&action=Update
[Mon Mar 14 13:08:54 2011] [error] [client -] PHP Warning: Invalid argument supplied for foreach() in .../public_html/lib/globals.php on line 19, referer: xxx.com/admin/businessadadd.php?iBusAdID=4&action=Update
Because it's just a string. Do you execute the query? If so, what does mysql_error tell you?
And please, pretty please, Google for SQL injection. This code is very vulnerable.
The reason its failing is explained by your statement:
and I'm not sure why
1) you've cited a fragment of the code used to generate the query - but we need to see the query which gets sent to the database and the structure of the table
2) we also need to see the error message that is returned after the query fails.
3) since you are using $_REQUEST, we also need to see your variables_order setting for both PHP installations to determine how $_REQUEST is populated
I expect once you find the answers to these the solution will be obvious. But it's also worth noting that splicing user supplied data into an SQL query is a very bad idea - you're wide open to SQL injection attacks.
You might try to use the concatenation you are doing at the end within the query. It might be look at the $_REQUEST['SOMETHING'] as a string.
$sql = "UPDATE businessad
SET iBUserID = '".$_REQUEST['iBUserID']."',
iCategoryID = '".$_REQUEST['iBCategoryID']."',
vAdTitle = '".$_REQUEST['vAdTitle']."',
tAdText = '".$_REQUEST['tAdText']."',
vAdImage = '$vAdImage',
vAdURL = '".$_REQUEST['vAdURL']."',
dStartDate = '".$_REQUEST['dStartDate']."',
dEndDate = '".$_REQUEST['dEndDate']."',
vAddress1 = '".$_REQUEST['vAddress1']."',
vAddress2 = '".$_REQUEST['vAddress2']."',
vCity = '".$_REQUEST['vCity']."',
vState = '".$_REQUEST['vState']."',
vZipCode = '".$_REQUEST['vZipCode']."',
vPhone = '".$_REQUEST['vPhone']."',
vEmail= '".$_REQUEST['vEmail']."',
eStatus = '".$_REQUEST['eStatus']."'
WHERE iBusAdID = '".$_REQUEST['iBusAdID']."'";
When you say your code works in PHP4 but stops working in PHP5, then it's easy to assume this is due to lack of magic_quotes. This feature has been disabled in the default configurations of PHP5. And your SQL query now became invalid due to lack of escaping.
At the start of your script (but after the mysql_connect) add following:
$_REQUEST = array_map("mysql_real_escape_string", $_REQUEST);
It's workaround-ish, but at least safe if it is always executed right after the database connection. Do the same for $_GET and $_POST if you must. (The correct approach would be to migrate to PDO and parameterized SQL, or at least apply the mysql_real_escape_string function wherever you concatenate SQL queries.)

Categories