SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: php error

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

    php error

    hi all,
    i have written the program for deleting multiple records using php.
    it is displaying the error as " Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\multi.php on line 33
    "
    dont no what went wrong....
    below ids the code........
    "multi.php"
    Code:
    <?php  
    $host = "localhost";  
    $user = "root";  
    $pass = "";  
    $con = 0;  
    $dbs = 0;  
    $re = 0;  
    $se = 0;  
    $C = mysql_connect($host,$user,$pass);  
    if($C)  
    {  
        $con = 1;  
    }  
    $D = mysql_select_db("test",$C);  
    if($D)  
    {  
        $dbs = 1;  
    }  
    $Q = mysql_query("SELECT * FROM emp");  
    if($Q)  
    {  
        $re = 1;  
    }  
    if(mysql_num_rows($Q) > 0)  
    {  
        $se = 1;  
    }  
    if($con == 1 && $dbs == 1 && $re == 1 && $se == 1)  
    {  
        echo "<form method=\"post\" action=\"p.php\">";  
        while(($dat = mysql_fetch_assoc($Q)) !== false)  
        {  
         echo "<input type=\"checkbox\" name=\"id[]\" value=\"$dat[empno]\" />" . $dat['empno'] . ": " . $dat['empname'] . ": " . $dat['desig'] "<br />";  
        }  
        echo "<input type=\"submit\" value=\"delete\" />";  
        echo "</form>";  
    }  
    ?>
    below is "p.php"
    Code:
    <?php  
    $uv = $_POST['id'];  
    $cs = 0;  
    $host = "localhost";  
    $user = "root";  
    $pass = "";  
    $con = 0;  
    $dbs = 0;  
    $ct = 0;  
    $ac = 0;  
    $C = mysql_connect($host,$user,$pass);  
    if($C)  
    {  
        $con = 1;  
    }  
    $D = mysql_select_db("test",$C);  
    if($D)  
    {  
        $dbs = 1;  
    }  
    
    if($uv)  
    {  
        $cs = 1;  
    }  
    if($cs == 1)  
    {  
        if(is_array($uv))  
        {  
            $ac = count($uv);  
              
            if($con == 1 && $dbs == 1)  
            {  
                foreach($uv as $k)  
                {  
                    $Q = mysql_query("DELETE FROM emp WHERE empno = '".$k."'");  
                      
                    if($Q)  
                    {  
                        $ct++;  
                    }  
                      
                }  
                echo "You sent " . $ac . " items to be deleted. " . $ct . " items where deleted!";  
            }  
            else  
            {  
                echo "not connected to server and no database selected";  
            }  
              
        }  
        else  
        {  
            echo "not an array";  
        }  
    }  
    ?>
    please tell me what is the error......

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You are missing a period in your code, i have highlighted it in red as to where it needs to be.

    Code:
    echo "<input type=\"checkbox\" name=\"id[]\" value=\"$dat[empno]\" />" . $dat['empno'] . ": " . $dat['empname'] . ": " . $dat['desig'] . "<br />";
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)


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
  •