SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    deleting records

    here i have written to delete using javascript......
    it is "del.php"
    Code:
    <script>
    function fundel(sno)
    {
    rv=confirm("u want to delete");
    if(rv==true)
    {
    location="delete.php?seno="+sno;
    }
    }
    </script>
    <table border="2">
    <?php
    mysql_connect("localhost","root","");
    mysql_select_db("test");
    $data=mysql_query("select * from emp");
    while($rec=mysql_fetch_row($data))
    {
    echo "<tr><td>$rec[0]<td>$rec[1]<td>$rec[2]</tr>
    <input type="button" value="delete" onclick='fundel($rec[2])'>";
    }
    ?>
    also is the "delete.php"
    Code:
    <?php
    $qs=$_REQUEST['seno'];
    mysql_connect("localhost","root","");
    mysql_select_db("test");
    mysql_query("delete from emp where sno=$qs");
    header("location:getrec.php");
    ?>
    it is displaying the error as Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\del.php on line 19

    tell me what went wrong....
    whether it will delete the values.....

  2. #2
    SitePoint Enthusiast LSC-Rob's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, NSW Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ravi951 View Post
    here i have written to delete using javascript......
    it is "del.php"
    Code:
    echo "<tr><td>$rec[0]<td>$rec[1]<td>$rec[2]</tr>
    <input type="button" value="delete" onclick='fundel($rec[2])'>";
    You've got inverted commas (") inside your echo's inverted commas. Either change the internal inverted commas to single quotes (') or escape the inverted commas (\").
    Rob G.
    ShopManager - Sales & Repair Business Management Software


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
  •