Different behavior of jQuery.load function in local PC and server - php

I used jQuery.load function to generate some dynamic page. I used POST method to send some data. The problem is, in my local PC (windows with Apache/php server) everything works fine, but when I upload it to my hosting server in internet (linux with Apache/php), it automatically add slashes to my string. Is jQuery have different behavior in different OS?
$("#fetch").click(function(){
klist ="'a','b','c'";
nlist ="'x','y','z'";
$("#mydiv").load("tor.php", {n: nlist, k: klist},function(){
$("#div2").hide();
});
Output of $_POST['n'] in tor.php is:
Local server: "'x','y','z'"
Internet Hosting server: "\'x\',\'y\',\'z\'"
Same for other variable.
Why it is happening and how to avoid this?

Rather than get into a whole thing about how you should install Linux on your local computer, the problem is that the remote server has the ini setting magic_quotes_gpc enabled. Either disable this setting or just call stripslashes on all of the $_POST values.

Related

ixudra get to localhost

I try to send curl to localhost with package called ixudra in laravel.
here is the code :
$url = 'localhost/fa_quality/public/api/qualities';
$response = Curl::to($url)
->enableDebug('./logFile.txt')
->get();
return $response;
but it's always return like below :
I tried my end point API postman, it work fine.
I try another end point such as https://jsonplaceholder.typicode.com/posts with withProxy method in ixudra and it work fine.
Im using xampp version 3.2.2. my computer run under proxy.
what am I doing wrong ?
I strongly doubt this has anything to do with the package. Most likely it's your setup. Usually when I see this, it's because your local webserver doesn't know how to interpret the "localhost" URL that you're using. Your Postman is an app that "lives" inside your host OS (I'm assuming Windows), which knows that an http request for "localhost" needs to be redirected to the VM instead of the internet.
I don't know xampp very well, but I work on Mac with an Ubuntu VM using vagrant. I'd fix this by SSH-ing into my VM and editing the hosts file to redirect HTTP calls FROM the VM to url "localhost" back TO the VM itself by adding the line 127.0.0.1 localhost. I would assume you can do something similar on xampp, but no idea how it works, sorry.

Minify 2.1.5 works on localhost but not on live server due to document root issue

The problem:
My /min/ files are in different places for my local and live server:
localhost/min/
/mnt/foo/bar/hello/example.com/web/content/min/ (from $_SERVER['DOCUMENT_ROOT'])
Min works fine on my localhost but after uploading the same files via ftp to my live server I get a 400 bad request error. This is clearly due the different document roots.
What I've tried:
Changing the $min_documentRoot = '' variable in config.php file to
$min_documentRoot = '/mnt/foo/bar/hello/example.com/web/content/'
Still gives the same errors.
Additional info:
My requests look like this:
src="/min/b=js&f=jquery.min.js,bootstrap.min.js,site.js"
What am I doing wrong?
how are you minifying? is it with zip?
make sure that the live and local servers both have the same setup. especially, make sure that they both have the required minification functions available to them. for example, the Zip PHP functions are not installed by default in Fedora installations.
check the online server's httpd error log

HTTP Get with variables

I have spent 2 days on this and are now stumped, having tried dozens of different methods and lots and lots of googling.
I need to retrieve data generated by a php page running on apache, using the GET command. This works fine when I am connecting with the LAN, but if I connect remotely then I am unable to get any response when there are variables in the path.
This works bot locally and remotely and I get the expected output from the php page.
GET /myfolder/mypage.php<CR><LF>
However, add a variable to the path and I get the correct response on the LAN but connecting remotely I get no response whatsoever:
GET /myfolder/mypage.php?var1=1&var2=2<CR><LF>
Just to reiterate, this works fine when accessing from the LAN and works fine in a web browser, but when I send as effectively a Telnet request I get nothing at all.
Any ideas ??
EDIT
The request is being sent to Linux Apache web server via a serial > tcpip gateway with a carriage return and linefeed at the end. The syntax works perfectly on the LAN with the ?var1= etc but as soon as I add ?var=1 when connecting externally nothing at all is returned, in fact apache logs don't show any record of the connection request.
I ## SUSPECT ## this may be something related to apache mod rewrite ?
May be can try something like below and specify the host and also the ver of HTTP being used.
GET /myfolder/mypage.php?var1=1&var2=2 HTTP/1.1
Host: 127.0.0.1

Php character coding

I have a file named index.php which using a mysql server gets a simple username. The mysql server is running on centOS and I have two different systems running apache serving as web servers.
One is my own windows pc using a "wamp" solution which uses the mysql server refereed before and the other is the centOS server itself.
I use this so I can develop in my laptop and run the final on the centOS box.
The problem is this:
Accessing centOS box I get (on hxxp://centos):
out_sider 1lu�s 2oi
Using wamp on windows I get (on hxxp://localhost):
out_sider 1luís 2oi
The mysql database is configured correctly seeing that both use the same and I used svn repository to move files from windows to centOS so the file is the same.
Does anyone have any suggestions?
Thanks in advnce
My first guess is its probably a locale thing, try adding or updating locale settings of the centOS, or try controlling it from PHP.
str = iconv(mb_detect_encoding(str)/*or insert the encoding type if you know it*/, "UTF-8", str);
and try also:
str = mb_convert_encoding (str, "UTF-8");
Also try connecting and querying the MYSQL server directly, to rule out the fact that it maybe the MYSQL table charset (on centOS) or something.

http://localhost/ not working on Windows 7. What's the problem?

I have a big problem opening http://localhost/ on Windows 7 (beta). I installed this os and everything went great; when I installed Wamp I saw that localhost is not working at all. I just see this error:
Failed to Connect
Firefox can't establish a connection to the server at localhost.
in Mozilla and Explorer.
I removed Wamp and after some weeks (that means two weeks from today) I installed NetBeans on Windows 7. I created a test PHP script and when I debug it, I get the same error again. I tried to access it with ip 127.... but still the same. What is the problem?
When i installed NetBeans I installed it in port 8080.
If you installed it on port 8080, you need to access it on port 8080:
http://localhost:8080 or http://127.0.0.1:8080
To fix the port 80 problem do:
From cmd as administrator:
sc config http start= demand (you need a space after the equal sign and not before)
Reboot
Run the command (netsh http show servicestate) as administrator to check that the port 80 is in use
After you have run this command, you can disable http.sys as follows:
net stop http (stop the process)
Sc config http start= disabled (if you want to disable the service forever)
it works for me.
Edit your C:\Windows\System32\drivers\etc\hosts file
Make sure there is an entry that looks like this:
127.0.0.1 localhost
If there is an entry like
:: localhost
Comment it out to look like this
\#:: localhost
This should fix your problem, I've had this problem in the past.
For me, it was skype causing the problem. Once I stopped skype, everything worked. I have 1.7.1 xampp (mysql and apache) running on Windows 7 x64.
It sounds like you have no web server running at all anywhere.
Have you tried enabling IIS and using it to display a basic html file first?
Programs & Features -> Turn Windows Features On/Off -> Internet Information Servcies
Then, place your html file in C:\inetpub\wwwroot\index.html and browse to http://localhost.
Once this works, try to get WAMP/php working. Be careful of port conflicts.
My initial thought is that you are missing an entry in the hosts file. Something like "127.0.0.1 localhost", however, you mention that you are getting a 404 error. That means that the webserver is connecting to your client/browser and responding to the request for a particular webpage.
I'm not familiar enough with Windows 7, however, I'm pretty sure that it does not include a webserver by default. Also, unless you actually code, build and run a webserver application using netbeans you're not going to get the desired response.
When it comes down to it.... your issue is going to be one of the following:
1) you're serving static documents and the webserver is not configured to serve the files from whatever the proper DOCROOT should be. This includes PUBLIC folders in the user's directories. (the basic apache install include a basic homepage)
2) you have a dynamic webserver application where the controller is looking at the application path in order to decide what page to display or what function to execute. (see MVC - Controller). Basically incomplete implementation.
3) yet another configuration error: your website might actually define a virtual domain. (something other than localhost) so when you look for localhost in the URL the server might not be configured to provide a default page.
Uncommenting the following line in host file worked for me,
#127.0.0.1 localhost
Well you are getting a 404, so the web server is running, it just can't find the file.
Check the http.conf file. If it pointing to the right root directory?
If you are using different ports, then check http.conf to see if Apache is listening on the right port, or if apache is redirecting traffic on the port to anther root directory.
Maybe posting your http.conf file might help?
If you're still having this problem, try this:
Edit your hosts file (with elevated privileges)
Uncomment the line "#127.0.0.1 localhost" (ie- remove the #)
Save the file as is. hosts with no extension
In Win7 MS has decided to comment the localhost line with that msg that says it's handled in dns. I'm still not exactly clear what they're getting at, except maybe that they're telling folks to use dns for localhost resolution instead of the hosts file. Probably safer that way, anyway.
Yea, this was a pain for me as well.
So what i did was find the "Start Wampserver", just hit the start button and type it in.
Then right click on it , select properties.
I set it to run in XP servive pack 3 on the capatability tab.
I also checked the box "Run this program as an administrator".
Then I right clicked the WAMPSERVER on the System Tray, and re-started all services.
This worked perfect for me, hope this will help you as well.
Rob
Got any other Programs running ? msn ect... ? some bind to port 8080 then your webserver wouldnt start and would cause a 404 , try binding it to a different port 80 which its default should be
I got a 404 could not connect error then I set wampmanager.exe to run as Xp Sp3 and it seems to be working fine this can be done by
Right Clicking on it
Properties
click tab labled "Compatibility"
Tick Box just undeder "Compatibility
mode"
Select Windows XP (Service Pack 3)
Click Apply then OK
It was Skype interfering for me too. I changed the Skype settings (in Skype go to Tools > options > advanced > Connection and UNCHECK "use port 80 and 443 as alternatives for incoming connections") save then close Skype. I have Win 7 HomePremium 64 bit, had installed Xampp fine with MySQL running fine, but no matter how many times I started Apache (and console showed "Apache started") I still got the "firefox can't establish a connection" error in the browser. After Skype changes were saved, Apache showed the green "Running" and all working now thanks
For me this did the trick at port 80 in the end:
You have to disable the http.sys service manually via the registry:
Launch RegEdit:
Go to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
Add a new DWORD (32-bit) value
Name it ‘NoRun’ not including the quotes
Double click the new property
In the Value data field type ’1' not including quotes and click OK
Re-boot your computer
You should now find that Apache will start on port 80!
Have you try the iis? Go to Control Panel->Programs and Features->Turn Windows features on or off (side bar). Try installing or reinstalling the Internet Information Service. I've a windows 7 with iis, with .net and php, and it works great...
you have to install the service, go to wamp->Apache->Service->Install service, then a command prompt window will pop up, then press enter, and after a few seconds go to the same route Services-> and click Start/Resume service, and you ready
I had the exact same issue, and the solution is what someone has already said:
In the taskbar, click on the WAMP icon.
Go to Apache-->Service-->Install Service
Then go back by clicking and selecting Apache-->Service-->Start/Resume Service
This will allow the localhost function to work (keep in mind I had already changed the host file located under c:\windows\system32\drivers\etc to remove the # from the 127.0.0.1 line)
If you need to edit that file still, you need to right click on it and select Properties. Then go to the Security tab, and click the Advanced button. You then need to select the Users, click Edit and select "Full Control". This will enable you to edit it.
That being said, you need to ALSO install the MySQL service following the same procedure.
MySQL-->Service-->Install Service
Then go back by right clicking yet again and selecting MySQL-->Service-->Start/Resume Service.
And that should fix it all up in Windows 7!
Before installing Wamp, go to controlpanel=> Adminstrative tools => IIS Manager and turn off the IIS server. Install wamp and everything works fine. When IIS is on it also uses port 80. You can go through a lot of changing the ports and permissions for wamp but I have found this the quickest and easiest method of getting wamp to run successfully.
Try adding the following tags in the wwwroot folder web.config file. These tags should be added as a child of the configuration tags as below.
-configuration-
--system.webServer--
---validation validateIntegratedModeConfiguration="false" ---
--/system.webServer--
-/configuration-
Maybe Skype or other Application is using port 80.
This you can check in
Tools->Settings->Advanced->Connection
See the above solutions are very good.But whenever you get this 404 eroor,first see this.I am sure the problem will be solved...
Just go to httpd.conf file by clicking wamp server symbol in bottom right taskbar-Apache->httpd.conf... or c:\\wampt\\bin\\apache\\apache2.2.1\\conf\\httpd.conf and approximate on line no 46 you will find "Listen 80"...just make sure it is written "80" after Listen...if it not then change it to 80...And your problem will be solved...
Assuming there is no problem doing a lookup on localhost (to 127.0.0.1), you need to make sure your server is listening to 127.0.0.1.
netstat works in both windows an UNIX. You probably need "netstat -a" to display listeners.

Categories