I am having an issue with a site that I am moving onto a new server. This site is connected to a SQL Server database, and is working correctly in it's current location. However, the new location is having problems with a single mssql_execute. Here is a sample of the code:
function get_customer_select_info() {
$link = get_db_link();
$customer_all_command_text = "dbo.Customer_All";
$customer_all_stmt = mssql_init($customer_all_command_text, $link);
$search = "%";
mssql_bind($customer_all_stmt, "#parm1", $search, SQLVARCHAR, false, false, 15);
$result = mssql_execute($customer_all_stmt);
mssql_free_statement($customer_all_stmt);
return $result;
}
Calling the above function results in
Unable to load the webpage because the server sent no data.
Error code: ERR_EMPTY_RESPONSE
from Chrome.
get_db_link retrieves a new connection to the database, or returns the current one if it already exists. It is functioning correctly. I have tried just closing the link and creating a new one if one already exists, which had no effect on the error.
This is not a problem connecting to the database because before this stored procedure is executed, three others are called and executed correctly.
Another complication is that running a trace on the given database results in this stored procedure getting called on the database and being successful!
Commenting out the mssql_execute makes the page load correctly (minus the information that this function returns).
Again, the same exact code on the current server works correctly, but the code on the new server is causing problems. I can't obtain any debugging information from apache or php because it is not actually sending anything.
If you facing ERR_EMPTY_RESPONSE then i will suggest you to follow these steps
Refresh page and restart browser
Clean your cache and browser cookies
Check internet connection
Update Google Chrome
Check router
I am also sharing video tutorial where you will find the complete solution of given steps to resolve your problem here is the link
http://vimeo.com/60824619
Best of luck
Related
I have a website that uses LDAP authentication. I have two active directory servers for redundancy. If the primary server is down, authentication should be handled by the back-up server. I tried using the following to achieve this:
$LDAP_SERVER = "10.100.10.1";
$LDAP_SERVER_BACKUP = "10.100.10.2";
$ldap_mycorp = ldap_connect($LDAP_SERVER);
if(!$ldap_mycorp){
$ldap_mycorp = ldap_connect($LDAP_SERVER_BACKUP);
}
But I noticed that if the connection to the primary server failed, 'ldap_connect($LDAP_SERVER)' returns a resource id instead of false, which means the if statement is never used.
I came up with a workaround for this by adding some additional code later in the script, but there must be a solution to handle the problem within the above context?
The host name parameter can be a space separated list of host names. This means that the LDAP code will talk to a backup server if the main server is not operational. There will be a delay while the code times out trying to talk to the main server but things will still work.
$LDAP_SERVERS = "10.100.10.1 10.100.10.2";
$ldap_mycorp = ldap_connect($LDAP_SERVERS);
Is this what you are looking for?
http://php.net/manual/en/function.ldap-error.php
I have no idea what it returns when there is no error, but it should give you a step in the right direction. With the answer given to connect automatically to multiple servers if the previous failed, you should still check if the connection didn't have any errors ;)
I have a simple php Paypal ipn listener which inserts the raw POST data into an SQLite (v2) database. It was working. Then...it stopped working. (I don't recall making any changes to it.) It uses a basic php sample that Paypal provides using CURL to communicate with Paypal (followed by the db insert). It just gives a 503 Service Unavailable error now.
It works (minus actually doing anything :)) if I comment out the final line, that simple contains "sqlite_exec(...)".
Alternatively, a MySQL insert works fine.Mailing results works as well.
The SQLite database appears normal. Another script reads & updates as normal.
Web host sees no issues on the server side.
Can anyone make sense of this?
Or maybe there is a way to send the POST data to another script so that it gets processed separately, on its own, instead of altogether as one page?
Update: What I'm trying to insert is the "raw post data" string...
$raw_post_data = file_get_contents('php://input');
...as seen on the top line here under php sample code: https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623 . My script is the same except with an insert at the bottom, which basically looks like this:
$dbloc = "/db/ipn.sqlite";
if($db = sqlite_open("$dbloc", 0666, $sqlite_error)){}else{die ($sqlite_error);}
$datetime = date("Y-m-d H:i:s");
$data = $raw_post_data;
$sql="INSERT INTO Paypal (entrydate,verified,data) values ('$datetime',$verified,'$data')";
sqlite_exec($sql,$db);
From when are you getting this error ?
Paypal has done some IPN changes recently.
please check this links:
https://www.x.com/content/bulletin-ipn-and-pdt-scripts-and-http-1-1
http://www.tipsandtricks-hq.com/forum/topic/paypal-ipn-and-pdt-changes-effective-from-1st-february-2013
please let us know what you are trying to insert into the db.
I've got a PHP application and I'm having trouble getting a User object from the SESSION.
When saving the object I have the following code (some other file).
$_SESSION['user'] = serialize($user);
The problem begins when I try and load a file called timeline.php. The first time I load the page (after I've logged in and the SESSION['user] is set) the page works fine. When I refresh the page I get an error 500.
The error log shows this:
Call to a member function get() on a non-object in timeline.php on line 10.
The code from line 2-10 is this:
include_once('isUserLoggedIn.php');
require_once('classes/User.php');
session_start();
$user = unserialize($_SESSION['user']);
require_once('classes/Database.php');
$tweets = Database::getTimeline($user->get('user_id'));
Can anyone offer any reason for this?
UPDATE (1)
In timeline.php I added var_dump($user) to line 8. The first time I load the page it gives me the correct value.
The second time I load the page it gives me bool(false).
UPDATE (2)
The problem seems to be with the host (perhaps a setting in the php.ini file there). The company I was using is Fatcow. When I used someone elses host (1and1) the issue didn't happen.
When unserializing objects lots of strange things can occur, see the PHP manual page for more information.
http://php.net/manual/en/function.unserialize.php
This comment seems pertinent:
http://www.php.net/manual/en/function.unserialize.php#77826
I am wanting to grab a screenshot using PHP and on my local Vista machine.
For starters I just wanted to get the standard example set up:
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.libgd.org");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
When I run the script (command line), it opens up two IE windows. One (the first) remains empty and the second goes to the designated URL. The screenshot is taken, saved and the first window gets closed. The window that went to the URL remains open. The screenshot itself taken from the first, empty IE window.
How can I target the second window?
-- EDIT #1 --
After all the help from Breakthrough it still does not work on my system. :(
For now I am going to try to work it out with: http://iecapt.sourceforge.net/ or http://cutycapt.sourceforge.net/ which both seem to work during preliminary testing.
I am still interested in a "real" PHP solution.
What version of IE are you using (7 or 8)?
What happens when you set the Visible property of $browser after navigating to the page?
-- EDIT IN RESPONSE TO COMMENT --
Go to Start -> Run, and type in "services.msc"
In the list, ensure that the Server Service and Remote Procedure Call (RPC) services are both set to automatic. Also, make sure that the Remote Procedure Call (RPC) Locator service is set to manual...
Try that and let us know what happens. :)
-- EDIT #2 --
In your php.ini file, make sure that com.allow_dcom is set to "1".
For me also doesn't work, but I managed it to work but have no idea when it is, I guess it has to do with that message that comes up from interactive Serivces Detection, if I click view message and do something in internet explorer screen it got once screenshot, all in all one big S***
I am using CodeCharge Studio to finish a large PHP application. This question isn't really CCS related, but a bit more general. I have a web form that is supposed to allow CRUD capabilities with a certain SQL Server table, but the Inserts keep failing without throwing any errors. What would be the best way to debug this?
When I'm having trouble with dynamically generated SQL queries, I typically echo out the query and try running that query on the console for the DB. Or alternatively, you could write a simple PHP function that writes out strings to a file, and that way you don't have to display the query directly on your page, but instead in a log file.
See what the actually query is and then try doing that query directly on the DB. Then you know whether it's a PHP issue or a DB issue.
Then go from there, depending on the outcome.
If the query looks OK, double check that the user running the query has insert rights to the database.
I've been caught out by that before.
You can monitor all sql queries in mysql as shown in this site, once you enable logging, run the query manually and see why its failing..this should be good starting point.
In addition to what's mentioned before, I can add my recent discovery:
trigger_error(print_r($your_var,1),E_USER_ERROR);
So you can output and debug your variable, even if it's a complex script with redirects, where simple echo would not help.
Dmitri.
You should try using FirePHP and log all the SQL to your Firebug:
An Example would be:
$sql = "SELECT * FROM table"
if (!mysql_query($sql)) {
// In un successfull log to FireBug
FB::error($data, "SQL error: ".mysql_error());
}
You can also implement the FB::error call from your own function, so you can later deactivate this behaviour modifying your function:
function log_error($data, $msg){
//dont forget to deactivate in case the application goes live!
FB::error($data, $msg);
}
if (!mysql_query($sql)) {
// In un successfull log to FireBug
log_error($data, "SQL error: ".mysql_error());
}
Most of the database connection classes in CodeCharge have a 'debug' flag which will automatically write all the page's database commands at the top of the page.
For example, in an old PHP project of mine, 'Common Files' the file 'db_mysql.php' (line 27):
public $Debug = 0; ## Set to 1 for debugging messages.
Change to '1' and publish that file. Load the web page. Change back and re-publish when done.
I've used this in CCS for PHP and ASP projects, and is likely in the other languages (not sure if or where to find in .NET projects).