Jump to content

Live server not displaying the same as local WAMP


Go to solution Solved by travisco87,

Recommended Posts

I have been working on a blog program with a tag system. When I add tags and ask to display them to a certain webpage they all appear on my WAMP environment but not my live server. Any thoughts as to why this might be? Here is the code needed to display the tags. I am not sure if maybe live servers have restrictions that might be stopping it from displaying. 

 

This is on the main page to display the tags.

				<div class="widget">
		<?php
				
				echo '<h2>Tags</h2>';
				echo '<ul>';
				getTagCount($DBH);
				echo '</ul>';
		?>
			</div>

Next here is the function from the includes file.

function getTagCount($DBH) {
    
    //Make the connection and grab all the tag's TAG TABLE HAS TWO FIELDS id and name
            $stmt = $DBH->query("SELECT * FROM tags");
            $stmt->execute();
            $result = array();
            $result = $stmt->fetchAll();
            //For each row pulled do the following
            foreach ($result as $row){
                //set the tagId and tagName to the id and name fields from the tags table
                $tagId = $row['id'];
                $tagName = ucfirst($row['name']);
                
                //Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id
                $stmt2 = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId);
                $stmt2->execute();
                $tagCount = $stmt2->fetchColumn();
                
                //Print the following list 
                echo '<li><a href="blog_tags.php?tagId=' . $tagId . '"title="' . $tagName . '">' . $tagName . '(' . $tagCount . ')</a></li></form>';
                
            //End of loop - start again
            }
            
}

The "tags" database is structured like so 

id, name

 

The "blog_post_tags" is structured like so,

 

blog_post_id, tag_id

 

 

 

On the WAMP server it returns all of tags while the live server only returns the first one. Any suggestions on what is going on? If you need any other info please let me know. 

 

 

other than a mismatched closing </form> tag (there's no opening <form> tag in sight) being output inside of a loop and running queries inside of that same loop, there's nothing obviously wrong.

 

it would help if you did a 'view source' of the page in your browser, on both systems, so that you could tell what the actual html looks like. perhaps some broken html is hiding the results in the source on the page and causing the content to not be displayed. have you validated the resulting html page at validator.w3.org so that you know if the html is all valid?

 

it would also help if you looked in your database table using a tool like phpmyadmin on your live server to conform you actually have the data that you think.

  • Like 1

Ok looking over both sources I found that the live server stops and does not load the rest of the page. I ran it through the validation site and think I found the error.

 

  • Line 127, column 74: Element input not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)
    								<input id="newsbutton" type="submit" name="Submit" value="Signup">

 

This is the section directly above it. 

You just found your answer from validation.

<input id="newsbutton" type="submit" name="Submit" value="Signup">
</ul>
</form>

You can't put a submit button in an Unordered list as a child element as it is expecting a list element. Place it after the Unordered list.

Edited by hansford

Made the correct changes but it still stops at the first tag. Again on my WAMP server it is just fine, it is the live server that is having the problem. I use BlueHost, are there server settings that can limit the amount of information you can pull? 

  • Solution

FOUND IT!!! ok so the issue was with my calling statement with PDO::fetchColumn. I did a little more research and found that this is what you need to use to count elements in MySQL. 

 

 

Instead of this

//Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id
$stmt2 = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId);
$stmt2->execute();
$tagCount = $stmt2->fetchColumn();

I used this and it fixed my issue.

                $tagCount = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId)->fetchColumn();

Thank you guys for all your help, I learned a couple new features such as validator.w3.org and about using PDO statements. Keep it up! 

Congratulation Travisco87 - you kept working the problem. We can only assist with what we see code-wise. We cannot see your environment and anything you don't show us. You have a good future because you keep working the problem regardless.

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.