PHP Fail... undefined $end

Discussion in 'Software' started by LI_Geek_95, Apr 29, 2010.

  1. LI_Geek_95

    LI_Geek_95 Post-and-Run Geek

    Code:
    <html>
    <head><title>Automated Email Sender</title></head>
    <link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />
    <link rel="stylesheet" href="/templates/system/css/general.css" type="text/css" />
    <link rel="stylesheet" href="/templates/themza_j15_48/css/template.css" type="text/css" />
    <link rel="stylesheet" href="/templates/themza_j15_48/css/green.css" type="text/css" />
    <body>
    <h1>Magee Family Slideshow Maker & Email Sender</h1>
    <?php
    $dbhost = 'localhost';
    $dbuser = 'yukushi1_vidhit';
    $dbpass = '<!--PASSWORD-->';
    $title = "";
    $myname = "";
    $vidurl = "";
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('R');
    
    $dbname = 'yukushi1_vidhit';
    mysql_select_db($dbname);
    
    $name = "";
    $dastr = $_GET["name"];
    $j = mb_strlen($dastr);
    for ($k = 0; $k < $j; $k++) {
    $char = mb_substr($dastr, $k, 1);
    if ($char == "\\"){
    }
    else{
    if ($char == "'"){
    $name .= "\'";
    }
    else
    {
    $name .= $char;
    }
    }
    
    $sql = "SELECT * FROM `vidlist` WHERE `vidnm` = '".$name."' LIMIT 0, 30 ";
    
    $result = mysql_query($sql);
    if (!$result) 
    {
        die("An error has occured.<br />".$sql);
    }
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    //SEND EMAIL
    $to = $row['email'];
    $subject = $row['vidnm'];
    $msg = "<a href=".$row['url']."&type=ss&id=".$row['id'].">Click Here to view ".$row['vidnm']."</a><br />".$_GET["message"];
    $headers = "From: <!--FROMADDRESS-->\r\nContent-type: text/html";
    mail("$to", "$subject", "$msg", "$headers");
    echo "Sent to ".$row["email"]."<br />";
    }
    echo $name;
    echo "<form action=\"step5.php\">";
    echo "<input type=\"hidden\" name=\"id\" value=\"\">";
    echo "<input type=\"submit\">";
    echo "</form>";
    echo "</body>";
    echo "</html>";
    ?>
    
    I get an Undefined $end error, on line 62 (the very last line containing the ?> )
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    Everything I've found relating to this message seems to point to closing tags, in particular, the </html> tag. Do they NEED to be in PHP? Maybe try it in plain old HTML, after your script?

    Maybe I'm missing something, but I don't see why this:

    Code:
    echo "<form action=\"step5.php\">";
    echo "<input type=\"hidden\" name=\"id\" value=\"\">";
    echo "<input type=\"submit\">";
    echo "</form>";
    echo "</body>";
    echo "</html>";
    Could'nt be put outside your script. There's no variable calls, there's no conditions, why not eliminate some server-side processing? (albeit minor)

    Another thing that might give us more visibility it to view the rendered source (ie. the code that is sent to the client from the server). That would make it easier to spot a potential rendered code error, since at a glance, your server-side code looks clean.
     
  3. LI_Geek_95

    LI_Geek_95 Post-and-Run Geek

    This is what I have now:
    Code:
    <html>
    <head><title>Automated Email Sender</title></head>
    <link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />
    <link rel="stylesheet" href="/templates/system/css/general.css" type="text/css" />
    <link rel="stylesheet" href="/templates/themza_j15_48/css/template.css" type="text/css" />
    <link rel="stylesheet" href="/templates/themza_j15_48/css/green.css" type="text/css" />
    <body>
    <h1>Magee Family Slideshow Maker & Email Sender</h1>
    <?php
    $dbhost = "localhost";
    $dbuser = "yukushi1_vidhit";
    $dbpass = "[B]snip[/B]";
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('R');
    
    $dbname = 'yukushi1_vidhit';
    mysql_select_db($dbname);
    
    $name = "";
    $dastr = $_GET["name"];
    $j = mb_strlen($dastr);
    for ($k = 0; $k < $j; $k++) 
    {
     $char = mb_substr($dastr, $k, 1);
     if ($char == "\\")
     {
     }
     else
     {
      if ($char == "'")
      {
       $name .= "\'";
      }
      else
      {
       $name .= $char;
      }
    }
    
    $sql = "SELECT * FROM `vidlist` WHERE `vidnm` = '".$name."' LIMIT 0, 30 ";
    
    $result = mysql_query($sql);
    if (!$result) 
    {
        die("An error has occured.<br />".$sql);
    }
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    //SEND EMAIL
    $to = $row['email'];
    $subject = $row['vidnm'];
    $msg = "<a href=".$row['url']."&type=ss&id=".$row['id'].">Click Here to view ".$row['vidnm']."</a><br />".$_GET["message"];
    $headers = "From: [B]snip[/B]\r\nContent-type: text/html";
    if (!mail("$to", "$subject", "$msg", "$headers"))
    {
     echo "Sending failed to ".$to;
    }
    else
    {
     echo "Sent to ".$row["email"]."<br />";
    }
    }
    ?>
    <form action="step5.php">
    <input type="hidden" name="id" value="">
    <input type="submit">
    </form>
    </body>
    </html>
    
    But I'm still getting an Unexpected $end on line 63. (which is the </html>)
     
  4. PC-XT

    PC-XT Master Sergeant

    You are missing a close curly brace in here:
    Code:
       $name .= $char;
      }
    }
    
    $sql = "SELECT * FROM `vidlist` WHERE `vidnm` = '".$name."' LIMIT 0, 30 ";
    (from the for or if)
     
  5. DoctorMendel

    DoctorMendel Private E-2

    Re:

    Thanks for starting that topic.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds