Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Need Help with strings

sagar
Posts: 1
Joined: Mon Jul 06, 2009 2:27 pm

Need Help with strings

Unread post by sagar »

Hi,

i m working with nuBuilder and want help with strings

whenever i use string and click save, the string gets Quoted by \ after and before the
string.
for example if i use sql statement like

select * from customer where name='sagar'

after saving the form it gets converted to

select * from customer where cust_name=\'sagar\'

and i get error showing cannot execute the above statement. I tried to use both single quotes as well as double quotes.

But if i use id inplace of that it works fine
ex. select * from customer where cust_id=1 it works

also when i use this
document.getElementById('name').value after saving it gets converted to

document.getElementById(\'name\')

Any help ?
Thankyou,
michael
Posts: 40
Joined: Mon Jun 15, 2009 9:50 am

Re: Need Help with strings

Unread post by michael »

The extra \ is being inserted because PHP's magic quotes feature is turned on. nuBuilder will not work correctly with magic quotes on.

To turn magic quotes off, edit you php.ini and set the following options to Off.

Code: Select all

magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Need Help with strings

Unread post by cypherinfo »

Hello, same issue here and those settings were already set that way! If the php.ini you mean is that in the web server folder (apache mine). If you mean another php.ini config may you tell me where is it please?

N. B.: I have hand writed the SQL statement directly in the SQL field; no copy and paste!
I'm using your nuBUILDER on a windows vista business system.

Thank you.



Cypherinfo.
michael
Posts: 40
Joined: Mon Jun 15, 2009 9:50 am

Re: Need Help with strings

Unread post by michael »

Hi,


There may be a .htaccess file on another php.ini file overriding the magic quotes settings. Could you make a file inside the /productionnu2 directory where nuBuilder is installed and paste the following code into it? When you run it in a web browser, it will display exactly what PHP settings are being used for your nuBuilder installation. What gets printed out in the browser for the three magic quotes settings?

Code: Select all

<?php

echo "<pre>";
print_r(ini_get_all());
echo "</pre>";

?>

Regards

Michael
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Need Help with strings

Unread post by cypherinfo »

Hello, you are right. The parameters are not set as expected; see the attached image.

[magic_quotes_gpc] => Array
(
[global_value] => 1
[local_value] => 1
[access] => 6
)

[magic_quotes_runtime] => Array
(
[global_value] =>
[local_value] =>
[access] => 7
)

[magic_quotes_sybase] => Array
(
[global_value] =>
[local_value] =>
[access] => 7
)


Now I really do not know where to set those settings. May you help me please?



Cypherinfo.
Attachments
result.JPG
result.JPG (22.87 KiB) Viewed 13682 times
michael
Posts: 40
Joined: Mon Jun 15, 2009 9:50 am

Re: Need Help with strings

Unread post by michael »

How did you install nuBuilder? Is it installed in shared hosting, or did you install it on your own (Windows or Linux) machine?

The output is showing that magic quotes is turned on in the global php.ini file rather than an .htaccess file or a php.ini inside a web directory. If you are running your own machine, just search for instances of php.ini. In Windows, the file should be in C:\, C:\Windows, C:\PHP or C:\Program Files\PHP. In Linux, it should be in /etc, you can find it by running the following command at a terminal.

Code: Select all

find /etc -name php.ini
If you are using shared hosting, most providers allow you to put a php.ini file inside and web directory and the web server will merge those settings with the global settings when it executes the PHP code. If this is the case, you can simply put one inside your nuBuilder installation directory to control magic quotes.

I hope this helps, let us know if you have trouble locating the file or overriding the settings.
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Need Help with strings

Unread post by cypherinfo »

Hello, thank you for your interest. The issue is becoming more and more intersting.

Mine is a local Apache installation on windows vista business; it runs a Joomla website and some others Joomla sandboxes.
After a search I found two php.ini files of interest here:
c:\xampp\php\php.ini and
c:\xampp\apache\bin\php.ini

It seems after I run your php code in a browser the php file intersted is the second one. I changed the magic quotes as you suggested and when I try to run the same code by clicking the php file containing it I get the following instead of the information expected!

I tried to come back to the old settings of the magic quotes and... same result in the webpage as the attached image.

How ever is it no more possible to get the information with your:

<?php

echo "<pre>";
print_r(ini_get_all());
echo "</pre>";

?>

???



Cypherinfo.
Attachments
webpage.JPG
webpage.JPG (22.56 KiB) Viewed 13660 times
michael
Posts: 40
Joined: Mon Jun 15, 2009 9:50 am

Re: Need Help with strings

Unread post by michael »

Hmm, it seems that your Apache is no longer processing that script as PHP code. Did you change the file your created to test the php.ini settings in any way? Are your Joomla sites, nuBuilder and any other PHP files still running correctly on your server? It might be worth checking your Apache error log and see if anything gets logged when you run that PHP script and when you restart the Apache server. Your error logs should be located in c:\xampp\logs or c:\xampp\apache\logs.
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Need Help with strings

Unread post by cypherinfo »

Hello, after uninstalling and reinstalling xamp 1.7.1 that php code worked. And it seems (no value displayed) the settings was as requested.
Now, may be after some installations and uninstallations of web applications, the issue is back!

I really do not want to uninstall and reinstall again; may yopu help me to fix it please?
I have attached the Apache log of errors and nothing seems to be occurred there. I have attached its file anyway. There also a little snap of it.

Thank you.


Cypherinfo.

P. S.: May be of some help to know that when I try to open the php file with internet explorer I get a window asks me to download a file with the name testPHP I gave follow your advice; the strange issue appears only when I use Fireofox!
Attachments
error.7z
(41.97 KiB) Downloaded 416 times
apache log.JPG
apache log.JPG (75.75 KiB) Viewed 13607 times
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Need Help with strings

Unread post by cypherinfo »

Hello, another thing is that code works only when I insert the URL of the file in the address bar of Firefox; the issue occurs when I browse the folder and right click the PHP file with open with item.

Thank you.


Cypherinfo.
Post Reply