SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Feb 2009
    Location
    israel
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    An error messge: I tried to insert a paragraph to my code

    Hi everyone,
    Here is a code I wrote:
    Code:
    <?php
    $con=mysqli_connect("localhost","root","rootpass","tivonidb");
    if (mysqli_connect_errno($con))
      {
        <p class="SQLconnect">
    		echo "Failed to connect to MySQL: " . mysqli_connect_error();
    	</p>
      }
    else
    	{
    		echo "Success connecting to MySQL! " ;
    	}
    ?>
    Here come an error message that accompanies the above code:
    Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\tiv oni\scripts\tivoni_connect.php on line 5
    Can anyone tell me please where I went wrong?
    Thanks

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    HTML script and PHP scripts must be separated with tags:

    Try this
    Code:
    <?php
    $con=mysqli_connect("localhost","root","rootpass","tivonidb");
    
    if (mysqli_connect_errno($con))
    {
      echo '<p class="SQLconnect">';
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      echo '</p>';
    
    }else{
      echo "Success connecting to MySQL! " ;
    
    }
    ?>
    or this:
    Code:
    <?php
    $con=mysqli_connect("localhost","root","rootpass","tivonidb");
    
    if (mysqli_connect_errno($con)) { ?>
    
      <p class="SQLconnect">
    
    <?php echo "Failed to connect to MySQL: " . mysqli_connect_error(); ?>
    
      </p>
    
    <?php }else{  echo "Success connecting to MySQL! " ; }
    
    ?>
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  3. #3
    SitePoint Addict
    Join Date
    Feb 2009
    Location
    israel
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John_Betong View Post
    HTML script and PHP scripts must be separated with tags:

    Try this
    Code:
    <?php
    $con=mysqli_connect("localhost","root","rootpass","tivonidb");
    
    if (mysqli_connect_errno($con))
    {
      echo '<p class="SQLconnect">';
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      echo '</p>';
    
    }else{
      echo "Success connecting to MySQL! " ;
    
    }
    ?>
    or this:
    Code:
    <?php
    $con=mysqli_connect("localhost","root","rootpass","tivonidb");
    
    if (mysqli_connect_errno($con)) { ?>
    
      <p class="SQLconnect">
    
    <?php echo "Failed to connect to MySQL: " . mysqli_connect_error(); ?>
    
      </p>
    
    <?php }else{  echo "Success connecting to MySQL! " ; }
    
    ?>
    Small error for you, great progress for me !
    Thanks a lot John !

  4. #4
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    I love the quote about small error
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •