Solved

Why styling a <div> affect its above <div> which contain php codes?

Posted on 2016-08-19
21
64 Views
Last Modified: 2016-08-21
Hello;

I have a <div> which has 5 rows, in row 3 i have php codes that i retrieve from db and arrange with <div> tags,while these php codes works well,but i'm sure that has problem,specially in part of  $div,because when styling the row4,it affect row3(which conain these php codes),thanks for your help to find the problem.

 <div class="basic-div-5rows">
  <div class="row1-title-each-section">artandculture</div>
  <div class="row2-horizontallinemain-artandculture"></div>
  <div class="row3-datapakage-arrange-image300">

     <?php
		 
$query_artandculture = "select tbarticles.articleid,tbarticles.title,substr(tbarticles.articlebody,1,200) as description1,tbphotos.photofilename,tbarticles.deletitem ,tbarticlecategories.catid,tbcategories.parentid,tbarticles.mediastate,tbphotos.altdescription
	 
from  tbarticles 
INNER JOIN tbphotos on tbphotos.articleid = tbarticles.articleid 
INNER JOIN tbarticlecategories on tbarticlecategories.articleid =  tbarticles.articleid
INNER JOIN tbcategories ON tbcategories.catid = tbarticlecategories.catid

where tbarticles.deletitem='1'   AND (tbcategories.parentid ='1' or  tbcategories.parentid ='2' or tbcategories.parentid ='3')
ORDER BY tbarticles.articleid desc
LIMIT 12
";

$result_artandculture = mysql_query($query_artandculture);
$num_rows = mysql_num_rows($result_artandculture);
$div = "";
$folder = 'artandculture';
$pagefile = 'adetails.php';

if ( $result_artandculture) {
	
	 $i = 1;
     for ( $i=1 ; $i<=4; $i++){
	
		$div = "<div class='arrangepakage-wrapper'>"; 
		
        	$row = @mysql_fetch_assoc( $result_artandculture);
	
                $div .= "<div class='arrangepakage-row'>";
	        $div .= "<div class='arrangepakage-column1'>" .doArticle_image300( $row['articleid'], $row['title'], $row['description1']
	          ,$row['photofilename'], $row['parentid'], $row['catid'],$row['mediastate'],$row['altdescription'],$folder,$pagefile); 
	          
				
	         $row = @mysql_fetch_assoc( $result_artandculture);
	          $div .= "<div class='arrangepakage-column2'>" .doArticle_image300( $row['articleid'], $row['title'], $row['description1'],
		  $row['photofilename'], $row['parentid'], $row['catid'],$row['mediastate'],$row['altdescription'],$folder,$pagefile);
		      
		 
	        	$div .= "</div>";
	 
	                 $div .= "</div>";
	echo   "$div"; 
   
    $div="";
	 
	  
     }
	 }
	 
   ?>
   </div>

  <div class="row4-datapakage-arrange-image110">
   Row4
    </div>
  <div class="row5-more-articles-for-reading">
  Row5
  </div>
  
</div>

Open in new window

0
Comment
Question by:MOSTAGHASSI
  • 7
  • 6
  • 5
  • +1
21 Comments
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 125 total points
ID: 41763406
I'd look at the resulting HTML and count opening and closing div tags. I think you open 4 divs but only add two closing tags in each iteration...


for ( $i=1 ; $i<=4; $i++){
	
		$div = "<div class='arrangepakage-wrapper'>"; // one 
		...
                $div .= "<div class='arrangepakage-row'>";  // two
	        $div .= "<div class='arrangepakage-column1'>" ...; // three
	          $div .= "<div class='arrangepakage-column2'>"...; // four
		      
		 
	        	$div .= "</div>"; // one
	 
	                 $div .= "</div>"; // two
	echo   "$div"; 
   
    $div="";
	 
	  
     }

Open in new window

0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41763418
I have not tested this solution but you seem to have a couple of <div> tags missing. Hint: you can never go wrong with properly formatted code. Don't be afraid of using up space - condensed code is always going to trip you up. You should also read up on PHP's HEREDOC notation - it makes a huge difference for returning large blocks of text.
Here is my attempt to reformat your code. Take a look at where you are creating the output in the for loop. The code has been reformatted and there are some missing closing tags.

You can solve many problems of this nature just by reformatting your code and lining up tags. A decent code editor will help you in this regard by highlighting closing tags when you click on the open tags and vice versa.
<!-- PROPERLY FORMATTED CODE IS EASIER TO DEBUG -->
<div class="basic-div-5rows">
  <div class="row1-title-each-section">artandculture</div>
  <div class="row2-horizontallinemain-artandculture"></div>
  <div class="row3-datapakage-arrange-image300">

<?php
// HEREDOC NOTATION MAKES WORKING WITH LARGE BLOCKS 
// OF TEXT MUCH EASIER
$query_artandculture = <<< QUERY
SELECT 
  tbarticles.articleid,
  tbarticles.title,
  SUBSTR(tbarticles.articlebody,1,200) AS description1,
  tbphotos.photofilename,
  tbarticles.deletitem,
  tbarticlecategories.catid,
  tbcategories.parentid,
  tbarticles.mediastate,
  tbphotos.altdescription
FROM  tbarticles 
INNER JOIN tbphotos ON tbphotos.articleid = tbarticles.articleid 
INNER JOIN tbarticlecategories ON tbarticlecategories.articleid =  tbarticles.articleid
INNER JOIN tbcategories ON tbcategories.catid = tbarticlecategories.catid
WHERE tbarticles.deletitem='1' AND 
  (
    tbcategories.parentid ='1' OR  
    tbcategories.parentid ='2' OR
    tbcategories.parentid ='3'
  )
ORDER BY tbarticles.articleid desc
LIMIT 12
QUERY;

// mysql LIBRARY IS DEPRECATED - CONSIDER MOVING TO mysqli LIBRARY INSTEAD
$result_artandculture = mysql_query($query_artandculture);
$num_rows             = mysql_num_rows($result_artandculture);
$div                  = "";
$folder               = 'artandculture';
$pagefile             = 'adetails.php';

if ($result_artandculture) {
  $i = 1;
  for ($i=1 ; $i<=4; $i++){
    // PREPARE THE VARIABLES FOR THE VIEW
    $row = @mysql_fetch_assoc( $result_artandculture);
    $var1 = doArticle_image300( 
      $row['articleid'], 
      $row['title'], 
      $row['description1'],
      $row['photofilename'], 
      $row['parentid'], 
      $row['catid'],
      $row['mediastate'],
      $row['altdescription'],
      $folder,
      $pagefile);
      
    $row = @mysql_fetch_assoc( $result_artandculture);
    $var 2 = doArticle_image300( 
      $row['articleid'], 
      $row['title'], 
      $row['description1'],
      $row['photofilename'],
      $row['parentid'],
      $row['catid'],
      $row['mediastate'],
      $row['altdescription'],
      $folder,
      $pagefile);
      
    // USE HEREDOC AGAIN SO WE CAN PROPERLY ALIGN OUR TAGS
    // INJEJECT VARIABLES INTO VIEW USING { } 
    $div <<< DIV
    <div class="arrangepakage-wrapper">
      <div class="arrangepakage-row">
        <div class="arrangepakage-column1">{$var1} <!-- DID YOU MEAN TO CLOSE HERE --- (A) -->
          <div class="arrangepakage-column2">{$var2}</div>
        </div>
      <!-- CLOSING DIV MISSING HERE -->
      </div>
    <!-- ANOTHER CLOSING DIV MISSING HERE IF NOT IN (A) ABOVE-->
    </div>
DIV;
    echo   "$div"; 
    $div="";
  }
}
?>
  </div>
  <div class="row4-datapakage-arrange-image110">
    Row4
  </div>
  <div class="row5-more-articles-for-reading">
    Row5
  </div>
</div>

Open in new window

0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41763421
Another thing - you are using the mysql library - this has been deprecated (and removed) from later versions of PHP - you might want to consider moving over to mysqli - the change is not a radical one as mysqli uses much of the same conventions as mysql.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41763423
Julian did a very good job in reformatting your code. Since two divs have classes "..-column1" and "..-column2" that hints on them not being nested, just from the simple knowledge columns are not nested but one after the other (no technical knowledge just common sense). So before the column2 div starts the column1 div should be closed, most probably, because nesting it would mean column2 is inside column1, and that's wrong.

Anyway, the missing closing tags clearly explain why styling has effect on other divs. You have to have clean and complete HTML, browsers may mend some quirks, eg a <p> before a missing </p> browsers autoclose the previous paragraph, but that's not possible with any HTML tags. Divs can be nested, so the natural end of divs is unknown.

If you put pages through html validation you'd be pointed to such errors, it's worth using a html validator especially for generated html to test whether the html generation is clean.

Bye, Olaf.
0
 

Author Comment

by:MOSTAGHASSI
ID: 41763465
Thanks for all comments.

@Julian,i'm testing your codes and i have some problem, i try that send an image from the page that i want to arrange and will send you.
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 41763521
Just post the image here.

Here is an alternative to the code I posted before. I had to guess at the layout but Olaf's comments above I think are on the money. Remember we don't have a means of testing this and we don't have the full context. This code is provided as a guideline - not as a copy and paste solution. You need to work through the code, read the comments and then ensure that when you adapt your source that you do so in a way that is in line with what it is you want your code to do.
<!-- PROPERLY FORMATTED CODE IS EASIER TO DEBUG -->
<div class="basic-div-5rows">
  <div class="row1-title-each-section">artandculture</div>
  <div class="row2-horizontallinemain-artandculture"></div>
  <div class="row3-datapakage-arrange-image300">

<?php
// HEREDOC NOTATION MAKES WORKING WITH LARGE BLOCKS 
// OF TEXT MUCH EASIER
$query_artandculture = <<< QUERY
SELECT 
  tbarticles.articleid,
  tbarticles.title,
  SUBSTR(tbarticles.articlebody,1,200) AS description1,
  tbphotos.photofilename,
  tbarticles.deletitem,
  tbarticlecategories.catid,
  tbcategories.parentid,
  tbarticles.mediastate,
  tbphotos.altdescription
FROM  tbarticles 
INNER JOIN tbphotos ON tbphotos.articleid = tbarticles.articleid 
INNER JOIN tbarticlecategories ON tbarticlecategories.articleid =  tbarticles.articleid
INNER JOIN tbcategories ON tbcategories.catid = tbarticlecategories.catid
WHERE tbarticles.deletitem='1' AND 
  (
    tbcategories.parentid ='1' OR  
    tbcategories.parentid ='2' OR
    tbcategories.parentid ='3'
  )
ORDER BY tbarticles.articleid desc
LIMIT 12
QUERY;

// mysql LIBRARY IS DEPRECATED - CONSIDER MOVING TO mysqli LIBRARY INSTEAD
$result_artandculture = mysql_query($query_artandculture);
$num_rows             = mysql_num_rows($result_artandculture);
$div                  = "";
$folder               = 'artandculture';
$pagefile             = 'adetails.php';

if ($result_artandculture) {
  $i = 1;
  for ($i=1 ; $i<=4; $i++){
    // PREPARE THE VARIABLES FOR THE VIEW
    $row = @mysql_fetch_assoc( $result_artandculture);
    $var1 = doArticle_image300( 
      $row['articleid'], 
      $row['title'], 
      $row['description1'],
      $row['photofilename'], 
      $row['parentid'], 
      $row['catid'],
      $row['mediastate'],
      $row['altdescription'],
      $folder,
      $pagefile);
      
    $row = @mysql_fetch_assoc( $result_artandculture);
    $var 2 = doArticle_image300( 
      $row['articleid'], 
      $row['title'], 
      $row['description1'],
      $row['photofilename'],
      $row['parentid'],
      $row['catid'],
      $row['mediastate'],
      $row['altdescription'],
      $folder,
      $pagefile);
      
    // USE HEREDOC AGAIN SO WE CAN PROPERLY ALIGN OUR TAGS
    // INJEJECT VARIABLES INTO VIEW USING { } 
    $div <<< DIV
    <div class="arrangepakage-wrapper">
      <div class="arrangepakage-row">
        <div class="arrangepakage-column1">{$var1}</div>
        <div class="arrangepakage-column2">{$var2}</div>
      </div>
    </div><!-- CLOSING DIV MISSING for arrangepakage-wrapper -->
DIV;
    echo $div; 
    // NOT REALLY NECESSARY AS THE ASSIGNMENT ON
	// LINE 74 WILL RE-INITIALISE
    $div="";
  }
}
?>
  </div><-- close row3-datapakage-arrange-image300 -->
  <div class="row4-datapakage-arrange-image110">
    Row4
  </div>
  <div class="row5-more-articles-for-reading">
    Row5
  </div>
</div><-- close basic-div-5rows -->

Open in new window

0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41763530
Yes, you couldn't have expected Julians first post to be a solution, his comments were asking you for actions to add missing </div>s, and he hinted at three possible places:

<!-- DID YOU MEAN TO CLOSE HERE --- (A) -->
<!-- CLOSING DIV MISSING HERE -->
<!-- ANOTHER CLOSING DIV MISSING HERE IF NOT IN (A) ABOVE-->

So don't just copy & paste, act on these comments.

Now his code should most probably solve that, based on my assumptions about what the class names mean. Anyway, the recommendation for validation services remain. There are online and offline validators and you may download and install offline validators, especially since online validators can't help you with localhost tests. For example a html-validator add on for firefox could show missing html code. A validator might also find something else additonal to missing </div> closing tags. We don't have your data, so we can't test your code, this is up to you only.

Bye, Olaf.
1
 

Author Comment

by:MOSTAGHASSI
ID: 41763555
Julian,thanks for your codes and yes if the codes be in sort it help finding the problem, I have attached the screen image of arrangement the data that i want retrieve and,i know that maybe my idea for this is not good,but i know that i'm not professional,i explain my idea and if you know better way please  let me know.

As you see in .png image with function of doArticle_image300() i arrange data for each block(articletitle,image,description) the function codes are as below:

 <?php
	 function  $var2 = doArticle_image300( 
      $row['articleid'], 
      $row['title'], 
      $row['description1'],
      $row['photofilename'],
      $row['parentid'],
      $row['catid'],
      $row['mediastate'],
      $row['altdescription'],
      $folder,
      $pagefile) {
	  //this if is for detecting of audio or video +article and putting speaker or play icon beside title //
	  if ($mediastate == 'audio'){
	 $audioicon="<img src='./images/speaker-icon20x16.gif' border='0' >";
	 }elseif ($mediastate == 'video'){
	 $audioicon="<img src='./images/youtube-playicon28x20.gif' border='0' >";
	  }else{
	 $audioicon="";
	 }
	 
	// CREATE A RETURN STRING IN HEREDOC NOTATION
    $tab = <<<EOD
    <div class='wrapper-for-datapakage-image300'>
      <div class='row1-articletitle-datapakage-image300'><a href='./$folder/$pagefile?articleid=$articleid&parentid=$parentid&catid=$catid'><strong>$title$audioicon 
		   </strong></a></div>
      <div class='row2-image-datapakage-image300'><a href='./$folder/$pagefile?articleid=$articleid&parentid=$parentid&catid=$catid'>
		   <img src='./images/mimage/$photo' border='0' alt='$altdescription' align='center' /></a><br/></div>
      <div class='row3-description-datapakage-image300'>$description1...</div><hr class='hr95' ></hr></div>
    </div>
EOD;
 return $tab;
$tab = "";
}
?>

Open in new window


and then call the function in my codes that you have modified.
When i use your codes the arrangement completely change,of course now that you can see the .png you can modify it (In your codes line 60 must change to  $var 2 and line  74 must change to $div=<<< DIV as my syntax error).

Thanks
first-pagae-screen.fw.png
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 125 total points
ID: 41763559
It looks like you have gotten pretty good answers here.  A little explanation might help.

PHP is a server-side language.  When the HTTP request is received at the server, PHP runs and it creates the HTML, CSS, and JavaScript statements that get sent to the client browser.  The HTML, CSS and JavaScript may be generated directly by PHP or brought in from libraries, but the important point is this:  Before the client begins to see the HTML document, the server has finished its work , disconnected, and PHP has gone dormant to wait for the next HTTP request.  The fact that the source code shows some PHP inside a <div> has nothing to do with this order of events.  The server runs, disconnects, then the browser renders the document.  The PHP code you see in the middle of the <div> has already run and has generated HTML that is now inside the <div> once the document begins to appear in the browser viewport.  This <div> may contain other <div> tags, if the PHP generated some internal <div> tags.  You cannot know this from looking at the PHP source code.  Instead you should run the script and examine the resulting HTML with view source.

What does this mean for your debugging process?  It means that you have multiple facets of the problem and all of them must be correct for the application to work correctly.  

On the server side, you have PHP and MySQL.  In the instant case, one thing working against you is the MySQL extension.  You MUST get off  the MySQL extension and the sooner you do it, the better.  This article tells why and how to get off MySQL and onto one of the supported extensions.  The article has tested-and-working code examples.  There may be other issues with your query (I don't know), but that's a separate question for another time.

On the client side, you have HTML, CSS and JavaScript (jQuery, AngularJS, etc).  These things need to be right, too.  One of the best tools for getting a rough-cut view of your document is the W3 validator.  You can put your code on a test server, copy your URL, paste it into the validator, and see right away if there is anything wrong with the HTML markup.  As but one example, it will show you if there are any <div> tags that are mismatched.
https://validator.w3.org/

There are other testing tools for JavaScript and CSS.  JSLint might be helpful, etc.

The overall point here is that you have several different technologies working together, with complex interactions among them.  In order to get a useful result, each must be correct, independent of the others, and all must interact correctly.  So your thought process must be to make these technologies as independent as possible in order to test them.  Here is what you're dealing with.

Server-side
MySQLi is the data model
PHP is the logic engine

Client-side
HTML is the semantic markup language
CSS is the appearance and layout styling tool
JS is the animation and behavior tool

When your code mixes HTML and PHP, that's a recipe for confusion.  Julian has shown you a way, using HEREDOC, to reduce the confusion and noise that comes from mixing PHP and HTML.  This mix-in of logic and semantic markup is a leftover artifact of PHP in the 1990's.  Nobody would ever do that today, but it's a capability that was built into PHP decades ago and it's too late to take it out now.  The best thing we can do is tell you to avoid it!  Most modern application frameworks separate logic from presentation, usually through a Model-View-Controller design.  It's a good idea to follow their practices.

Similarly, it's helpful to be able to deconstruct the database queries from the PHP logic.  I see that the query used a LIMIT 12 clause, but the PHP logic used a counter to limit output to 4.  Which is canonical?  You should choose one or the other, probably the query, and let it be the limiting factor.

As Olaf points out, we cannot really test the solutions we propose here.  That's because we do not have your test data.  If you want to get the best answers from E-E or any other learning opportunity, you may want to learn about the SSCCE.  It teaches how to ask a question.  If you want to learn a little more about test data, this article has some perspectives on testing that may help you get good answers faster.
https://www.experts-exchange.com/articles/7830/A-Quick-Tour-of-Test-Driven-Development.html

Finally, I see that you used the error-control operator.  NEVER do that!  Always visualize all the errors!  Set error_reporting(E_ALL).  Visualize and correct the errors.  Suppressing the error messages is like putting a piece of black electrical tape over the warning lights in your car's dashboard.  It makes the light go away, but it does nothing to correct the underlying problem.  In the end, the uncorrected problems, whether in the car or in your programming, are likely to cause much more trouble than you want.

So that's the high-level explanation.  Isolate the parts of your application into small, homogeneous pieces.  Debug the pieces one-at-a-time.  Once each piece works correctly, start looking at the integration of these pieces into the "big picture."
1
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41763567
Very nice summaration and additional advice, Ray. One thing to note about the advice to turn error reporting to E_ALL, is that this is good for developement and testing, on the site itself in public, the inverse to really hide all errors is safer in the aspect of not giving anyone hints on how to best attack your site to get at data, mails, credit card info, or simply resources, like hooking into there to use your database and webspace, place ads, whatever is valuable to hackers.

For that reason, php installations come with a suggested php.ini configuration for testing/development and site/production with the two files php.ini-development and php.ini-production. Your localhost installation should start off with renaming php.ini to php-ini-backup and then rename php.ini-development to php.ini. That'll not suppress errors for any localhost test.



But Ray is right and I didn't spot this: Wherever you used @mysql_fetch_assoc you turned off that debug informations, the helpfulness of this operator only comes from having a custom error handler and take all the advice given in http://php.net/manual/en/language.operators.errorcontrol.php, otherwise this just undermines the purpose of the verboseness about errors and warnings in development. Since you get output as shown in your PNG screenshot that's not your current concenr, most probably, but who knows what shows up, when you remove the @ operator everywhere you use it.

Rays article https://www.experts-exchange.com/articles/12293/AntiPHPatterns-and-AntiPHPractices.html also mentions both these things in bullet points 4 and 5. I just stress out once more, showing ALL errors just is fine for development, in production all the details of errors, which might happen and lead to an incomplete or wrong output should only be verbosely logged, but not shown to users. You might even reroute to a general error page in that case, even exaggerating and returning a 500 internal server error is practised to disguise what really went wrong. An error handler could for example send out a header("HTTP/1.1 500 Internal Server Error");

Your code should be good enough to seldom error out in any way, so your site keeps working.

Bye, Olaf.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:MOSTAGHASSI
ID: 41763574
Please see the image png that i have attached ,this result is according my codes that i know it has some problems for closing the </div> tag inside php.

@Olaf ,i know that my codes has problem for closing the </div> tags inside php,you always advise but would you please correct that codes in question and send to me.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41763576
A screenshot isn't good for seeing what's wrong. Please lookout for a html validation plugin or add on for your browser and let it show you missing or wrong tags.

Bye, Olaf.
0
 

Author Comment

by:MOSTAGHASSI
ID: 41763577
@@Olaf,please see the attachment,my codes work and i don't get errors(the result of these codes are in attachment!!!!),but and but for closing the </div> i know it has problem,please and please note  that i dont get errors.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41763580
In that aspect, PHP does not trip on HTML errors, but the browser, therefore validate the HTML output, you'll be pointed to HTML and CSS errors. Please do html validation.

Your screenshot shows the visual result, not HTML code, I don't know what you expect instead and what's wrong in your opinion, I don't have any comparison with expected layout. Also we can only mend HTML, not a screenshot. We could only get at the final HTML output of your PHP, if we had your database, but we don't. Another possibility would be, if you have this in the web and not just on localhost and simply could point to the page with layout problem with a link to it.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41763589
Have you considered using a framework like Bootstrap - it can do what you want quite nicely and it is responsive which means it scales to mobile well

You would do something like this
<html>
<head>
...
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<style type="text/css">
.block-image {
  display: block;
}
</style>
</head>
<body>
...
  <div class="row">
    <div class="col-md-6">
      <h3 class="image-title">Image Title</h3>
      <img src="images/foreground1.png" class="block-image"/>
      <div class="subscript">This is the description</div>
    </div>
    <div class="col-md-6">
      <h3 class="image-title">Image Title</h3>
      <img src="images/foreground2.png" class="block-image"/>
      <div class="subscript">This is the description</div>
    </div>
    </div>
  <div class="row">
    <div class="col-md-6">
      <h3 class="image-title">Image Title</h3>
      <img src="images/foreground3.png" class="block-image"/>
      <div class="subscript">This is the description</div>
    </div>
    <div class="col-md-6">
      <h3 class="image-title">Image Title</h3>
      <img src="images/foreground4.png" class="block-image"/>
      <div class="subscript">This is the description</div>
    </div>
  </div>
...
</body>
</html>

Open in new window

You can see a sample here
1
 

Author Comment

by:MOSTAGHASSI
ID: 41763596
Thanks Julian,would you please let me know that can we use from bootstrap beside the DW ?If you want design a dynamic site do you use bootstrap for layout designing and mix it with php?
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41763602
@Olaf: Regarding error_reporting() here is a strategy I've used with good success.  Since it's fairly clear that the Author is still in the development stage, displaying the errors is probably a good idea.  At the same time, I agree that understanding the whole concept of error reporting, logging, and control is a necessary part of being a developer.

1. Set error_reporting(E_ALL) for all versions of the site.
2. Set log_errors(TRUE) for all versions of the site.
3. Set display_errors(TRUE) for the test version - instant visual identification of errors.
4. Set display_errors(FALSE) for the deployed version - errors are hidden from the browser.
5. Run a CRON job to locate and display error_log.  If it finds anything, send an automated email, SMS or Tweet to the administrator.

Regarding the use of the @error-control operator, that is an anti-practice.  It temporarily sets error_reporting(FALSE) for one line of code.  The errors will still occur, they just will be silent.  If a developer uses the operator, I would expect to see a prominent comment in the code explaining why, including what the expected errors are, and what specific problem error suppression will solve.  MySQL is not a black box; it can and will fail for reasons that are sometimes outside of the control of the PHP script.  For that reason I think it's a good practice to be instantly aware of MySQL failures, since they are inevitably entangled with other (data-dependent) errors in the script.

Suppressing the error reports on a line-by-line basis creates a situation where we get "spooky action at a distance," as other parts of the software depend on variables that did not get populated because of the (MySQL) failure.  Where did the unexpected value come from?  Who knows?  These non-local issues are more time-consuming to debug.  It follows that bringing the error detection as close as possible to the error event makes for an easier path to dependable working code.

I recently came across this in a client refactoring project:

@mysql_connect(...);

Since we know that MySQL is going away, and is already gone in many PHP installations, the error suppression means that the script will fail silently  at some point in the future.  The only thing we do not know is when.
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41763612
If you read what Ray posted - PHP is just a means for "writing HTML" - instead of typing in HTML markup manually you write a PHP script that outputs HTML. The "mixing" you refer to is just PHP code that outputs HTML - the result is an HTML page with no evidence that PHP had anything to do with it.

Bootstrap is just a collection of CSS classes that allow you to do some nice things with layout. They use a grid system that is based on 12 columns (or combinations thereof). You use the grid to layout your page.

The row class groups the column classes together - your column classes specify how wide you want your columns to be.

So in answer to your question your PHP can be modified to output Bootstrap classes. I am not sure what DW means - but if you want to know more about what you can do with Bootstrap and how to do it then best go to the source (http://getbootstrap.com/) There are plenty of examples of the various Bootstrap components and styles on that site.
1
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41764528
Ray, this is just what I said in more detail. Yes, error reporting, ie logging of errors, should never be off, but error display can reveal risky information on site.

Bye, Olaf.
0
 

Author Comment

by:MOSTAGHASSI
ID: 41764532
Mr Wolfe,

Thanks for your help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Phone Dialer 5 38
writting html or javascript in PHP 8 15
Printing a Google Form 2 10
Post xml via PHP Soap Client 3 15
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now