hasithapriya111

Active member
  • Sep 1, 2010
    440
    54
    28
    machanla prashne mekai.man php igenaganna kenek.man liyapu code eke error msg ekak enawa.mata poddak kiyanna puluwanda kotanada weredda tiyenne kiyala.menna meka tamai code eka.


    PHP:
    <?php
        
    
        $result =mysql_query("SELECT * FROM subjects",$connection);
        if(!$result){
        
        die("connection error : ".mysql_error());
            }
        
        while($row = mysql_fetch_array($result)){
        
        
        echo $row["menu_name"]."<br/>";
        
        }
            
            
      $parent = mysql_query("SELECT * FROM pages WHERE subject_id = {$row['id']}" ,$connection);
        if(!$parent){
        die("connection error : ".mysql_error());
        }
           
            
        while($rowone = mysql_fetch_array($parent)){
            if($parent==$row["id"]){
                echo $rowone["menu_name"];
            
            }
                
        
        }
        
        
        ?>

    mennamekai machan error msg eka.

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
     

    cm2004cm4ever

    Member
    Aug 21, 2008
    1,079
    88
    0
    $connection kiyana part eka one.. $connection =

    tika missing neh puluwan nam full code eka danna balanna oya tiyena tike nam syntax error na wage kokatath FROM subjects kiyana ewwa FROM `subjects` danna
     

    amila325

    Well-known member
  • Jul 11, 2006
    9,188
    33
    48
    this is a mysql error not php so, make sure you used correct database in connection string.
    Then make sure there is a table called 'subjects'(FYI dont use plural for tables ;) just a good habit :P) that's all u can do :) :)
     

    hasithapriya111

    Active member
  • Sep 1, 2010
    440
    54
    28
    Code:
    <?php
    require_once("includes/connection.php");?>
    <html>
    <head>
    <style type="text/css">
    <!--
    a:link {
        color: #000000;
        text-decoration: none;
    }
    a:visited {
        text-decoration: none;
        color: #000000;
    }
    a:hover {
        text-decoration: underline;
        color: #FFFFFF;
    }
    a:active {
        text-decoration: none;
        color: #000000;
    }
    a {
        font-family: Courier New, Courier, monospace;
    }
    body,td,th {
        font-family: Courier New, Courier, monospace;
        font-size: 18px;
    }
    .style1 {font-size: 40px}
    
    #one {
    text-align:center;
    vertical-align:top;
    }
    #parent {
    position:absolute;
    left:60px;
    font-size:14px;
    }
    -->
    </style>
    </head>
    <body>
    
    
    <table width="100%" height="888" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="186" colspan="2" bgcolor="#CCCCCC"><div align="center" class="style1">DOWNLOAD TREASURE </div></td>
      </tr>
      <tr>
        <td id="one" width="16%" bgcolor="#99CCFF" ><?php
        $result =mysql_query("SELECT * FROM subjects",$connection);
        if(!$result){
        
        die("connection error : ".mysql_error());
            }
        
        while($row = mysql_fetch_array($result)){
        
        
        echo $row["menu_name"]."<br/>";
        
        }
            
            
                
            
        $q = "SELECT * FROM pages WHERE subject_id = {$row['id']";
        $parent = mysql_query($q,$connection);
        if(!$parent){
        die("connection error : ".mysql_error());
        }
           
            
        while($rowone = mysql_fetch_array($parent)){
            if($parent==$row["id"]){
                echo $rowone["menu_name"];
            
            }
                
        
        }
        
        
        ?></td>
        <td width="84%"> </td>
      </tr>
    </table>
    </body>
    </html>

    this is the full code