Jump to content

URGENT! Help requested from exp. php dev.


njdubois

Recommended Posts

I believe I posted here a few weeks ago about no Data Received errors I was getting on a godaddy host.

 

Well, now on another host, for another client I am having them again and am convinced I am doing something wrong.  I google the error and I get so many different things that it only confuses me more!  I absolutely must figure out what I am doing wrong!

 

I'm not going to post the code here, but include a link to a zip file containing the code in question.  I'm hoping that seeing the actual code may help!

 

http://www.beaconfasteners.com/seek_help.zip

 

The site is of course live at www.beaconfasteners.com and if you go to product -> catalog it will never populate the menu on the right, and the dev menu/console tells me : ERR_EMPTY_RESPONSE when trying to do an AJAX call to the php file that fills the left menu.

 

If you go to about us -> Ad Archive

The page wont even load?

 

The only change I have made to this attached code is inside the INCLUDE_mysql_connect_file.php.  I have removed the username and password.

 

On line 48 of header_content.php you will see:

<?php
//if ($search=="true") {
// echo $search_html;
//}
?>
[EDIT]$search_html == "" on all pages except the catalog page.[/EDIT]
 
If i un-rem that chuck of code out, index.php returns "No Data received" error.  Why???  If I leave it remed out index.php works.
 
I've no doubts that a well experienced php developer will be able to at least narrow down my issue!  So please please please PLEASE take a look at the linked zip file.  Examine my code.  Let me have it.  If I'm an absolute idiot, tell me, if it's a simple fix tell me, ANYTHING.
 
I am going to be sitting here watching for a reply so if you have a question, I'll be very fast to answer!
 
I'm so very grateful for the ability to even post here, thanks for reading this, thanks for trying, and of course, thanks for everything!
 
Nick
Edited by njdubois
Link to comment
Share on other sites

you need to have some error checking logic on all your database queries. you also need to have php's error_reporting set to E_ALL (in your php.ini) and for debugging have display_errors set to ON (again in your php.ini) and when not debugging the site, have display_errors set to OFF and log_errors set to ON.

 

i suspect either the database queries are failing due to a problem with the table name (capitalization or spelling) or fatal php parse or run-time errors.

Link to comment
Share on other sites

Hi,

Bare in mind that mysql_ functions are deprecated.  You should move to mysqli or PDO for compatibly of future versions of php.

 

As for the code, it is difficult to see where the error could be.

 

Also note the following:
When you add ?show_id=1 for example to your about us page, it works....  Well, doesn't end executing...  So the line "$id_to_show=$_GET['show_id'];" is probably to blame...

 

Now, usually this is a warning not an error, so your config must be different (I assume).

 

You could change it to: $id_to_show = (isset($_GET['show_id']) ? $_GET['show_id'] : DEFAULT_ID_HERE);

 

Please make sure you validate/escape this before using it in a query...

 

Hope this helps

Link to comment
Share on other sites

I am just losing it today.  First I posted this post 3 times, and now I type a long reply and close the tab.  I hate having a cold!

 

@ mac_gyver:

 

There was not a php.ini file, so I created it and inserted this code into it:

 

display_errors = on
error_reporting = E_ALL
 
It is my understanding that there needs to be a server reboot before it will take effect?  Currently there is no visible change, nothing else being displayed.
 
I am pretty sure that it isn't a database table casing issue.  I should have mentioned this before and I apologize.  The site had been working fine since we switched to this host a few months ago.  I had added a user log in form and a login/log out link to the footer earlier this morning.  Everything was ok.  The client asked that I keep the login log out links hidden so I removed that code and shortly after these problems started.
 
This is similar to what I went through with the other client on a godaddy host.  Everything was fine for years and then it just stopped working.  We narrowed down the issue to one to many ajax requests caused the app to get flagged by the firewall and marked as a DDoS.  This was because godaddy had changed their policy.
 
In this case, there is little to no ajax requests, zero on the index.php home page.  I can rem the beacon bulletin include out and there is zero ajax and zero database code.  I put that search_html code back in and bam, No data received error.
 
@ kierany5 :
 
I un remed the ajax call to fill the ad archive up.  Wouldn't load and I noticed in the dev console i get this error: ERR_INCOMPLETE_CHUNKED_ENCODING.
 
When I add ?show_id=1 the page works as it is expected.  No issue.  This just confuses me even more!
 
i will be switching to the updated mysqli stuff first thing when this site is back up.  Are you sure this is the issue?  Even when there is no database code I have issues.
 
This is my current plan.  Tomorrow I will be able to get a hold of the client and get the info needed to talk to the web host.  I did talk to them earlier but without proper credentials there wasn't much they could do.  They did say that the problem is probably in the script, which is the same thing godaddy told me.  I will have the php.ini stuff setup so if there is any errors I'll be able to track that down.  I will post any of them here.
 
I really think this ERR_INCOMPLETE_CHUNKED_ENCODING error is a great clue.  Any thoughts on that?
 
Could this be anything to do with using WinSCP to do my development work?  I notice when I open the downloaded file in notepad there is no CRLFs?  I realize I'm clutching for straws!
 
Thanks so much for the assistance, and for any future assistance!
 
Nick
Link to comment
Share on other sites

Hi,

 

The mysql_ thing won't be causing the critical error (unless it is not installed, which I assume it is).

 

To enable error reporting without using php.ini (which is often untouchable on shared hosting), you should put in code (at the top somewhere),

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>

WinSCP shouldn't be an issue, nor should having no CRLFs.

 

$_GET['show_id'] is not set when there is no ?show_id in the URL.  So you are assigning a value that does not exist to the variable.  This may be causing issues with your current setup.

 

To be honest, I reckon you are using a very strange PHP setup.  I've never known a script to break because a $_GET variable hasn't been set.

 

On the catalog page, I'm getting ERR_EMPTY_RESPONSE.  Simply put, the server is sending no data...

Edited by kierany5
Link to comment
Share on other sites

A very strange php setup indeed!

 

A quick update for you.  I put the error reporting code on the top of the Ad Archive and it isn't spitting anything out.

 

It gets stranger!

 

If I do this:

 

$id_to_show=1;//$_GET['show_id'];

 

It works.  That variable isn't being used anywhere.  I removed it from the javascript.  That is the only part of the code that has it.  Removing it completely and the page stops working, put the get back in without added the URL stuff, and it doesn't work.

 

so for now I am going to leave it set to 1.  It isn't doing anything, but at least that page is working.

 

I am really looking forward to talking to my client, and the web host tomorrow as I am sure there is something odd going on that I may not have control over!

 

Thanks a million for the fast reply!

 

Nick

Link to comment
Share on other sites

An update.

 

I called the host.  They wouldn't look at the code, nor the ftp sever at all.  Also they told me that the site worked find on their end, which doesn't help me at all.

 

for giggles, I uploaded the code to my own host:

http://www.beacon.nickscanvas.com/

 

and surprise, it works fine!

 

I am recommending that my client switches hosts.  Any other thoughts?

 

Thanks,

Nick

Link to comment
Share on other sites

Hi,

 

This pretty much confirms that the main issue is the PHP setup with your current hosts.

 

I have used many shared hosting in the past, I don't want to start advertising but Google has many results...

 

I haven't used a third-party shared hosting service in 2 years now.  I've now got a multi-server setup around Europe in a few data centres...

 

Most shared hosters offer PHP support now, just don't be caught in by all the unlimited offers they provide.  You don't need it, and they don't really supply it.  But that isn't much of an issue.

 

If your client isn't stuck on a contract, moving hosts could be a quick solution (well, 48 hours), but recommend a host that will last.  The other solution would be to track down the errors in the code and solve them...  Just saying...

 

Hope it goes ok though, which ever direction you go in.

Link to comment
Share on other sites

I am going to be receiving a phone call from the web/scripting department for the host.  I have little faith they will help as from their end everything is working. This tells me there is something between us and them inside their system that is causing the problem.

 

You're absolutely right about tracking down the errors in the code.  I still get confused why the code did work and now it doesn't.  That tell's me there isn't an error in the code.  I still think it has to be something!  

 

The client has not been happy with the host in general and are slowly starting the ball to switch to another host.  

 

Thanks for following me on this, I really appreciate it!

 

Nick

Link to comment
Share on other sites

the symptoms (if not due to a broken server/php installation) of unexplained operation that doesn't match what the code should be doing are typical of the code being ran on the server not being the same code you are looking at, either because the upload/ftp to the server failed, there are multiple copies of the code on the server at different paths and you are including the wrong file(s) (possibly due to php's include_path setting), or the server has disk-caching (or even a php bytecode cache) set to an extremely long cache time and changes to the files aren't taking effect immediately.

 

also, the .zip file you linked to, at the time i grabbed a copy, doesn't contain any code that sets the variables $search, $search_html..., so it's obviously not the actual code you are writing about and for a case where entire web pages don't function as expected, it takes having all the code (less any database credentials) to either prove or eliminate the code as the cause of the problem.

 

btw - in just the index.php code, you have a bunch of repetitive, hard-coded html, that only differs in one line of content, a minor variation of a class name and an id. if you are going to the trouble of using a server-side scripting language, you might as well put the programming language to work for you, rather than write out block after block of code that's hard to maintain, troubleshoot, and reuse. for just the slide html (you can use this same technique to reduce the code for the tiles), using php to dynamically produce the repetitive sections, reduces the number of lines in the index.php file by half - 

// define the content/differences for the slide html
$slide_content[1] = '<a border="0" outline="0" href="images/DINLineCard(Front Only).pdf"target="_blank"><img border="0" outline="0" src="images/slide_images/Linecardslide.jpg" alt="line card" width="100%" height="100%" style="height:425px;"></a> <br />';
$slide_content[2] = '<img src="images/slide_images/StockReleaseslide.jpg" alt="" width="100%" height="100%" style="height:425px;">';
$slide_content[3] = '<img src="images/slide_images/in-housetestingslide.jpg" alt="" width="100%" height="100%" style="height:425px;">';
$slide_content[4] = '<img src="images/slide_images/QualityPerformance.jpg" alt="" width="100%" height="100%" style="height:425px">';
$slide_content[5] = '<img src="images/slide_images/99OnTime.jpg" alt="" width="100%" height="100%" style="height:425px">';
$last = ''; // build the class = "slide last" html after 1st pass through loop
?>
            <div id="header_container" class="header_container">
                <table width="100%" >
                    <tr>
                        <td colspan="2" style="margin-top:25px;background-color:#cccccc;">
                            <div class="slider_holder" id="my_slides">
<?php
foreach($slide_content as $id=>$content){
?>
<div class="slide<?php echo $last; ?>">
    <div class="whole_slide_container">
        <div class="slide_control_button_container_left" onclick="previous();" >
            <table height="100%"><tr><td valign="middle" align="center" >
                <img src="images/slide_images/leftArrow.png" />
            </td></tr></table>
        </div>
        <div class="slide_content_container">
            <?php echo $content; ?>
        </div>
        <div class="slide_control_button_container_bottom" id="pause_slide_<?php echo $id; ?>" onclick="pause(this.id);" >PAUSE</div>
        <div class="slide_control_button_container_right" onclick="next();">
            <table height="100%"><tr><td valign="middle" align="center">
                <img src="images/slide_images/rightArrow.png" />
            </td></tr></table>
        </div>
    </div>
</div>
<?php
$last = ' last'; // 2nd and higher loops
}
?>
Link to comment
Share on other sites

This forum has already done more than the host has.  Thank you so much!

 

I have updated the zip file:

 

http://www.beaconfasteners.com/seek_help.zip

 

To include the catalog folder. On line 18, before it calls header_content.php you see this:

 

$search="true";
$search_html='<input type="text" placeholder="Search By Part Number" style="padding-left:10px;padding-right:10px;" id="search" name="search" onfocus="get_Cataloge_Items_List();" onkeyup="get_Cataloge_Items_List();" />';
// THIS NEXT LINE INCLUDES THE HEADER CONTENT
include("../header_content.php");
 
This is the only place those variables are being set.
 
If you go to:
beacon.nickscanvas.com
you can see the site live and working.  If you go to Products -> Catalog you will notice in the top right a search box appears.  That is the reason for these variables.
 
Funny enough, this host is soooo much faster too.
 
Currently, there is a web development department of the host looking into this problem.  They have had a link to this forum post, this link:
 
Which shows the basic explanation of the issue I am having.
 
And they have access to the FTP server and the database.  I am awaiting details from them.  I hope they read what you just posted, as it seems clear the problem is on the server.
 
About your last section about the slide show code.  I am aware I could have used PHP to do the dirty work, I actually use php and a database to do the beacon bulletin.  Because I have out sourced to a graphics guy that handles the slides it was easier this way as he doesn't know php.  In the future, as I add web admin functionality, I will switch that over as the client will be adding their own slides.
 
Thanks for all the assistance, I will keep you all posted as to what the host development team finds!
 
Nick
Link to comment
Share on other sites

After a long wait, we finally heard back from the web development department associated with the host.  It was the code, sort of.  Half code, half server:

 

This version (or configuration) of PHP fails when a variable is used without being defined. 

For the first problem in the /error document, I found that the variables $search and $search_html were not defined anywhere. First use on line 48 caused the page to fail. 

In the second problem, the variable $id_to_show, was indeed being used. 

Line 74: //var show_id='<?php echo $id_to_show; ?>'; 

the // comments out the javascript, but the php still executes. Thus the failure took place when $id_to_show was undefined.

I've never seen a PHP that behaved like this, but both pages are working now and we only went a little over the 1 hour allotted.  If there was a ripple effect and different errors are now present, let us know and we will need to handle it under a new work order with additional time given.

 

So now I am stuck trying to figure out how to pass the variable to show the search box only on one page.  I have had little success with this.

 

First off, I put the html for the search box inside the header_content.php file.  This way I don't have to pass that back and forth and have to worry about that variable.  But, anything I do to pass the search is true variable to the header file blows up the page again as it is undefined.  

 

So, something like this:

 

on the catalog.php page:

 

     include("../content_header.php?search=true");

 

inside content_header.php:

 

     if ( isset( $_GET['search'] ) ) { $search = $_GET['search']; }

 

blows up the whole site.  No Data Received.

 

Solution:

 

I used session variables.

     if (isset($_SESSION['search']) ) { $search = $_SESSION['search']; }

 

 

Is there any other way?

 

Thanks

Nick

 

[EDIT] I need a way to use $_GET[''] even when it will be empty.  suggestions?  Thanks

Edited by njdubois
Link to comment
Share on other sites

$myValue = (isset($_GET['myKeyName']) ? $_GET['myKeyName'] : defaultValue);

So when $_GET['myKeyName'] is not set, it uses defaultValue.   

 

You can't include("../content_header.php?search=true");

 

​You can access $_GET variables set on the parent script in the child script....  E.g.

 

I go to /example.php?search=test

 

In example.php:

<?php
include('include.php');
?>

In include.php

<?php
echo $_GET['search'];
?>

Hope that makes sense.

 

{addition}

$_GET is a Superglobal, as documented here: http://php.net/manual/en/language.variables.superglobals.php

 

Same as $_POST, $_SERVER, etc.  These are set when PHP starts running the script.  The include functions don't start a new PHP process, it brings the include script into your current script and runs it.

Edited by kierany5
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.