Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ''leave''

Tags:

sql

php

mysql

I always get this error when i run my code

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 ''leave'' at line 1

Here is my coding part

<?php
        $result = mysql_query("select * from 'leave'");
        if ($result == FALSE)
        {
            die(mysql_error());
        }
        while($row = mysql_fetch_assoc($result))
        {
    ?>
    <tr>
        <td><a href = "app_status.php? id = <?php echo $row["Leave_ID"];?>" target = "_blank"></a>Leave ID</td>
        <td><?php echo $row["Emp_ID"];?></td>   
        <td><?php echo $row["Date_Apply"];?></td>
        <td><?php echo $row["Leave_Type"];?></td>
        <td><?php echo $row["Leave_Start"];?></td>
        <td><?php echo $row["Leave_End"];?></td>
        <td><?php echo $row["Status"];?></td>
    </tr>
    <?php
        }

    ?>
like image 364
JJ___ Avatar asked Mar 22 '23 15:03

JJ___


1 Answers

Don't use single quaots

You can try it as

 $result = mysql_query("select * from leave");

Or use ` key

 $result = mysql_query("select * from `leave`");
like image 102
Naveen Kumar Alone Avatar answered Mar 25 '23 19:03

Naveen Kumar Alone