Jump to content

Archived

This topic is now archived and is closed to further replies.

balkan7

[resolved] What im Missing

Recommended Posts

Parse error: parse error, unexpected $end in C:\web\5\index.php on line 380

index.php
[code]<?php
//------------------------------------------
//database connection
mysql_connect("localhost", "root", "123450") or die(mysql_error());
mysql_select_db("dzeki") or die(mysql_error());
//end database connection
//------------------------------------------

//------------------------------------------
//echo out a navigation panel
echo "
<center><a href='index.php'>Pregled na Kategoerii</a> | <a href='index.php?akcija=dodaj'>Dodaj SoftwareAdd Tutorial</a></center>
";
//------------------------------------------

//------------------------------------------
//begin main navigation (tutorials.php?action=)
switch($_GET['action'])
{
  //------------------------------------------
  //this case adds a tutorial.
  //pretty self-explanitory
  //------------------------------------------
  case "dodaj":
  //if the form to enter a new
  //tutorial hasn't been submitted,
  //show it
  if(!isset($_POST['dodaj']))
  {
  echo "
  <table border='0' cellpadding='0' cellspacing='0' width='500'>
  <form action='$self?akcija=dodaj' method='post'>
      <tr>
          <td>Sifra:</td>
          <td><input type='text' name='sifra'></td>
      </tr>
      <tr>
          <td>Naslov:</td>
          <td><input type='text' name='naslov'></td>
      </tr>
      <tr>
          <td>Opis:</td>
          <td><textarea name='opis' cols='40' rows='5'></textarea></td>
      </tr>
      <tr>
          <td>Kategorija:</td>
          <td>
              <select name='kategorija'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_kategorija ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi -</option>";
              echo "<option value='$row[id]'>$row[kategorija]";
          }
                    echo "
              </select>
          </td>
  </tr>
  <tr>
          <td>CD & DVD:</td>
          <td>
              <select name='cd'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_cd ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi CD -</option>";
              echo "<option value='$row[id]'>$row[cd]";
          }
                    echo "
              </select>
          </td>
      </tr>
  <tr>
      <td>Novo?</td>
      <td><input type='checkbox' name='novo' value='1' checked></td>
  </tr>
  <tr>
      <td colspan='2'><center><input type='submit' name='dodaj' value='Submit New Software'></center></td>
  </tr>
</form>
</table>
";
}
//else, error check, enter it
elseif(isset($_POST['dodaj']))
{
      $name = mysql_real_escape_string(strip_tags($_POST['name']));
      $naslov = mysql_real_escape_string(strip_tags($_POST['naslov']));
      $opis = mysql_real_escape_string(strip_tags($_POST['opis']));
      $kategorija = mysql_real_escape_string(strip_tags($_POST['kategorija']));
      $cd = mysql_real_escape_string(strip_tags($_POST['cd']));
      $novo = mysql_real_escape_string($_POST['novo']);
      $datum = date("m/d/Y");
     
      //we begin error checking....
      $error_msg = array();
      if(empty($name))
      {
          $error_msg[] = "Please insert a name!<br />";
      }
      if(empty($naslov))
      {
          $error_msg[] = "Please insert a naslov!<br />";
      }
      if(empty($opis))
      {
          $error_msg[] = "Please insert a opis!<br />";
      }
      if(empty($kategorija))
      {
          $error_msg[] = "Please insert a kategorija!<br />";
      }
      if(empty($cd))
      {
          $error_msg[] = "Please select CD!<br />";
      }
      //print the errors, if any
      if(count($error_msg)>0)
      {
          echo "<strong>ERROR:</strong><br>\n";
          foreach($error_msg as $err)
              echo "$err";
      }
      //everythings ok, insert it to the DB
      else
      {
          $sql = "INSERT INTO software (sifra, naslov, opis, kat_id, cd_id, novo, datum, validen) VALUES ('$sifra', '$naslov', '$opis', '$kat_id', '$cd_id', '$novo', '$datum', '0')";
          mysql_query($sql) or die(mysql_error());
          echo "Softwerot e uspesno dodaden, za pregled!";
      }
  }
  break;
 
  //------------------------------------------
  //this case gets the specified [ID] in the url
  //(tutorials.php?action=viewcategory&id=[ID]
  //and gets all the tutorials listed under that
  //category ID (cat_id)
  //------------------------------------------
  case "pregled":
  //if there is an ID given...
  if($_GET['id'])
  {
  //get the id, put it into a variable, cast to an INT
  //(for security purposes)
  $id = (int)$_GET['id'];
  $query = mysql_query("SELECT * FROM software WHERE kat_id = '$id' AND validen = '1'") or die(mysql_error());
 
  //if no results, show that there are no tutorials
  //for that category
  if(mysql_num_rows($query) == 0)
  {
  echo "Nema software vo ovaa Kategorija!";
  }
  //else, there is..show em
  else
  {
  echo "<h1>Softwares</h1>";
  //loop through the tutorials
  //show all tutorials
  echo "<table border='0' cellpadding='0' cellspacing='0' width='500'>";
  while($row = mysql_fetch_array($query))
  {
  echo "
      <tr>
          <td>Sifra:</td>
          <td><b>$row[sifra]</b></td>
      </tr>
      <tr>
          <td>Naslov:</td>
          <td><b>$row[naslov]</b></td>
      </tr>
      <tr>
          <td>Opis:</td>
          <td>$row[opis]</td>
      </tr>
      <tr>
          <td>Kategorija:</td>
          <td>$row[kat_id]</td>
      </tr>
      <tr>
          <td>CD & DVD:</td>
          <td>$row[cd_id]</td>
      </tr>
      <tr>
          <td>Novo:</td>
          <td>$row[novo]</td>
      </tr>
      <tr>
          <td>Datum:</td>
          <td>$row[datum]</td>
      </tr>
      <tr>
          <td>Izmeni:</td>
          <td colspan='2'><b><a href='$self?akcija=izmeni&id=$row[id]'>Izmeni</a></b></td>
      </tr>
      <tr>
          <td colspan='2'><hr /></td>
      </tr>
  ";
  }
  echo "</table>";
  }
}
else
{
echo "Momentalno nema Softwares!";
}
break;

//------------------------------------------
//this case gets the given [ID]
//action=viewtutorial&id=[ID]
//and gets that tutorial ID from the database
//and displays it!
//------------------------------------------
case "izmeni":
//if there is an ID given..
if($_GET['id'])
{
//set $id to the URL id, cast to an INT
//for security purposes
$id = (int)$_GET['id'];

//query the database
$query = mysql_query("SELECT * FROM software WHERE id = '$id'") or die (mysql_error());

//if no rows returned...
if(mysql_num_rows($query) == 0)
{
echo "That ID is not in the database!";
}
//else, show it!
else
{
//update the views for this tutorial!
$popravi = mysql_query("UPDATE software SET naslov = '$naslov', opis = '$opis', kat_id = '$kat_id', cd_id = '$cd_id', novo = '$novo' WHERE id = '$id'") or die(mysql_error());

//loop through the database
while($row = mysql_fetch_array($query))
{
echo "
<table border='0' cellpadding='0' cellspacing='0' width='500' style='border: 1px solid black; padding: 3px;'>
    <tr>
        <td colspan='2'>Software: <b>$row[naslov]</b></td>
    </tr>
    <tr>
              <td>Naslov:</td>
              <td><input type='text' name='naslov' value='$row[naslov]'></td>
          <tr>
              <td>Opis:</td>
              <td><textarea name='opis' cols='40' rows='5' value='$row[opis]'></textarea></td>
          </tr>
          <tr>
          <td>Kategorija:</td>
          <td>
              <select name='kategorija'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_kategorija ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi -</option>";
              echo "<option value='$row[id]'>$row[kategorija]";
          }
                    echo "
              </select>
          </td>
  </tr>
  <tr>
          <td>CD & DVD:</td>
          <td>
              <select name='cd'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_cd ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi CD -</option>";
              echo "<option value='$row[id]'>$row[cd]";
          }
                    echo "
              </select>
          </td>
      </tr>
  <tr>
      <td>Novo?</td>
      <td><input type='checkbox' name='novo' value='1' checked></td>
  </tr>
  <tr>
      <td colspan='2'><center><input type='submit' name='izmeni' value='Submit New Software'></center></td>
  </tr>
</form>
</table>
          </tr>
    <tr>
        <td colspan='2' style='border: 1px solid black;'><center><b>Software</b></center><br />$row[text]</td>
    </tr>
    <tr>
    ";
  }
    //----------------------------
    //this part of the code
    //checks to see if the submitter
    //wants an email left for support
    //----------------------------
    $new = "Novo";
    if($row['novo'] == 1)
    {
    echo $new;
    }
    echo "
    </tr>
    <tr>
        <td><hr /></td>
    </tr>
";
  }
//------------------------------------------
//default case, this is shown default
//in this instance, we are going to make the default case show
//all the categories that you can view tutorials on
//------------------------------------------
$query = mysql_query("SELECT * FROM software_kategorija") or die(mysql_error());
//if the number of rows returned is 0, then say, no categories
if(mysql_num_rows($query) == 0)
{
echo "Nema Kategorii!";
}
//if anything else, then there has to be categories. show em.
else
{
echo "<h1>Software Kategorii:</h1> ";
//while loop to loop through the database and display results!
while($row = mysql_fetch_array($query))
{
    echo "
    <table border='0' cellpadding = '0' cellspacing='0' width='500'>
        <tr>
            <td>Ime za Kategorija:</td>
            <td>$row[kategorija]</td>
        </tr>
        <tr>
            <td><a href='$self?akcija=pregled&id=$row[id]'>Pogedni ja Kategorijata</a></td>
        </tr>
        <tr>
            <td><hr /></td>
        </tr>
      </table>
      ";
  }
}
    break;
}
//end navigation
//------------------------------------------
?>

[/code]

Share this post


Link to post
Share on other sites
There isnt even a line 380 anyways here this should be fixed.
[code]
<?php
//------------------------------------------
//database connection
mysql_connect("localhost", "root", "123450") or die(mysql_error());
mysql_select_db("dzeki") or die(mysql_error());
//end database connection
//------------------------------------------

//------------------------------------------
//echo out a navigation panel
echo "
<center><a href='index.php'>Pregled na Kategoerii</a> | <a href='index.php?akcija=dodaj'>Dodaj SoftwareAdd Tutorial</a></center>
";
//------------------------------------------

//------------------------------------------
//begin main navigation (tutorials.php?action=)
switch($_GET['action'])
{
  //------------------------------------------
  //this case adds a tutorial.
  //pretty self-explanitory
  //------------------------------------------
  case "dodaj":
  //if the form to enter a new
  //tutorial hasn't been submitted,
  //show it
  if(!isset($_POST['dodaj']))
  {
  echo "
  <table border='0' cellpadding='0' cellspacing='0' width='500'>
  <form action='$self?akcija=dodaj' method='post'>
      <tr>
          <td>Sifra:</td>
          <td><input type='text' name='sifra'></td>
      </tr>
      <tr>
          <td>Naslov:</td>
          <td><input type='text' name='naslov'></td>
      </tr>
      <tr>
          <td>Opis:</td>
          <td><textarea name='opis' cols='40' rows='5'></textarea></td>
      </tr>
      <tr>
          <td>Kategorija:</td>
          <td>
              <select name='kategorija'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_kategorija ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi -</option>";
              echo "<option value='$row[id]'>$row[kategorija]";
          }
                    echo "
              </select>
          </td>
  </tr>
  <tr>
          <td>CD & DVD:</td>
          <td>
              <select name='cd'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_cd ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi CD -</option>";
              echo "<option value='$row[id]'>$row[cd]";
          }
                    echo "
              </select>
          </td>
      </tr>
  <tr>
      <td>Novo?</td>
      <td><input type='checkbox' name='novo' value='1' checked></td>
  </tr>
  <tr>
      <td colspan='2'><center><input type='submit' name='dodaj' value='Submit New Software'></center></td>
  </tr>
</form>
</table>
";
}
//else, error check, enter it
elseif(isset($_POST['dodaj']))
{
      $name = mysql_real_escape_string(strip_tags($_POST['name']));
      $naslov = mysql_real_escape_string(strip_tags($_POST['naslov']));
      $opis = mysql_real_escape_string(strip_tags($_POST['opis']));
      $kategorija = mysql_real_escape_string(strip_tags($_POST['kategorija']));
      $cd = mysql_real_escape_string(strip_tags($_POST['cd']));
      $novo = mysql_real_escape_string($_POST['novo']);
      $datum = date("m/d/Y");
     
      //we begin error checking....
      $error_msg = array();
      if(empty($name))
      {
          $error_msg[] = "Please insert a name!<br />";
      }
      if(empty($naslov))
      {
          $error_msg[] = "Please insert a naslov!<br />";
      }
      if(empty($opis))
      {
          $error_msg[] = "Please insert a opis!<br />";
      }
      if(empty($kategorija))
      {
          $error_msg[] = "Please insert a kategorija!<br />";
      }
      if(empty($cd))
      {
          $error_msg[] = "Please select CD!<br />";
      }
      //print the errors, if any
      if(count($error_msg)>0)
      {
          echo "<strong>ERROR:</strong><br>\n";
          foreach($error_msg as $err)
              echo "$err";
      }
      //everythings ok, insert it to the DB
      else
      {
          $sql = "INSERT INTO software (sifra, naslov, opis, kat_id, cd_id, novo, datum, validen) VALUES ('$sifra', '$naslov', '$opis', '$kat_id', '$cd_id', '$novo', '$datum', '0')";
          mysql_query($sql) or die(mysql_error());
          echo "Softwerot e uspesno dodaden, za pregled!";
      }
  }
  break;
 
  //------------------------------------------
  //this case gets the specified [ID] in the url
  //(tutorials.php?action=viewcategory&id=[ID]
  //and gets all the tutorials listed under that
  //category ID (cat_id)
  //------------------------------------------
  case "pregled":
  //if there is an ID given...
  if($_GET['id'])
  {
  //get the id, put it into a variable, cast to an INT
  //(for security purposes)
  $id = (int)$_GET['id'];
  $query = mysql_query("SELECT * FROM software WHERE kat_id = '$id' AND validen = '1'") or die(mysql_error());
 
  //if no results, show that there are no tutorials
  //for that category
  if(mysql_num_rows($query) == 0)
  {
  echo "Nema software vo ovaa Kategorija!";
  }
  //else, there is..show em
  else
  {
  echo "<h1>Softwares</h1>";
  //loop through the tutorials
  //show all tutorials
  echo "<table border='0' cellpadding='0' cellspacing='0' width='500'>";
  while($row = mysql_fetch_array($query))
  {
  echo "
      <tr>
          <td>Sifra:</td>
          <td><b>$row[sifra]</b></td>
      </tr>
      <tr>
          <td>Naslov:</td>
          <td><b>$row[naslov]</b></td>
      </tr>
      <tr>
          <td>Opis:</td>
          <td>$row[opis]</td>
      </tr>
      <tr>
          <td>Kategorija:</td>
          <td>$row[kat_id]</td>
      </tr>
      <tr>
          <td>CD & DVD:</td>
          <td>$row[cd_id]</td>
      </tr>
      <tr>
          <td>Novo:</td>
          <td>$row[novo]</td>
      </tr>
      <tr>
          <td>Datum:</td>
          <td>$row[datum]</td>
      </tr>
      <tr>
          <td>Izmeni:</td>
          <td colspan='2'><b><a href='$self?akcija=izmeni&id=$row[id]'>Izmeni</a></b></td>
      </tr>
      <tr>
          <td colspan='2'><hr /></td>
      </tr>
  ";
  }
  echo "</table>";
  }
}
else
{
echo "Momentalno nema Softwares!";
}
break;

//------------------------------------------
//this case gets the given [ID]
//action=viewtutorial&id=[ID]
//and gets that tutorial ID from the database
//and displays it!
//------------------------------------------
case "izmeni":
//if there is an ID given..
if($_GET['id'])
{
//set $id to the URL id, cast to an INT
//for security purposes
$id = (int)$_GET['id'];

//query the database
$query = mysql_query("SELECT * FROM software WHERE id = '$id'") or die (mysql_error());

//if no rows returned...
if(mysql_num_rows($query) == 0)
{
echo "That ID is not in the database!";
}
//else, show it!
else
{
//update the views for this tutorial!
$popravi = mysql_query("UPDATE software SET naslov = '$naslov', opis = '$opis', kat_id = '$kat_id', cd_id = '$cd_id', novo = '$novo' WHERE id = '$id'") or die(mysql_error());

//loop through the database
while($row = mysql_fetch_array($query))
{
echo "
<table border='0' cellpadding='0' cellspacing='0' width='500' style='border: 1px solid black; padding: 3px;'>
    <tr>
        <td colspan='2'>Software: <b>$row[naslov]</b></td>
    </tr>
    <tr>
              <td>Naslov:</td>
              <td><input type='text' name='naslov' value='$row[naslov]'></td>
          <tr>
              <td>Opis:</td>
              <td><textarea name='opis' cols='40' rows='5' value='$row[opis]'></textarea></td>
          </tr>
          <tr>
          <td>Kategorija:</td>
          <td>
              <select name='kategorija'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_kategorija ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi -</option>";
              echo "<option value='$row[id]'>$row[kategorija]";
          }
                    echo "
              </select>
          </td>
  </tr>
  <tr>
          <td>CD & DVD:</td>
          <td>
              <select name='cd'>
                  ";
          //now what we are doing here is looping through
          //the categorys table and getting all the
          //categorys and putting them into a select
          //so the user can select which category
          //the tutorial is on
          $query = mysql_query("SELECT * FROM software_cd ORDER BY id ASC") or die(mysql_error());
          while($row = mysql_fetch_array($query))
          {
            echo "<option>- Izberi CD -</option>";
              echo "<option value='$row[id]'>$row[cd]";
          }
                    echo "
              </select>
          </td>
      </tr>
  <tr>
      <td>Novo?</td>
      <td><input type='checkbox' name='novo' value='1' checked></td>
  </tr>
  <tr>
      <td colspan='2'><center><input type='submit' name='izmeni' value='Submit New Software'></center></td>
  </tr>
</form>
</table>
          </tr>
    <tr>
        <td colspan='2' style='border: 1px solid black;'><center><b>Software</b></center><br />$row[text]</td>
    </tr>
    <tr>
    ";
  }
    //----------------------------
    //this part of the code
    //checks to see if the submitter
    //wants an email left for support
    //----------------------------
    $new = "Novo";
    if($row['novo'] == 1)
    {
    echo $new;
    }
    echo "
    </tr>
    <tr>
        <td><hr /></td>
    </tr>
";
  }
//------------------------------------------
//default case, this is shown default
//in this instance, we are going to make the default case show
//all the categories that you can view tutorials on
//------------------------------------------
$query = mysql_query("SELECT * FROM software_kategorija") or die(mysql_error());
//if the number of rows returned is 0, then say, no categories
if(mysql_num_rows($query) == 0)
{
echo "Nema Kategorii!";
}
//if anything else, then there has to be categories. show em.
else
{
echo "<h1>Software Kategorii:</h1> ";
//while loop to loop through the database and display results!
while($row = mysql_fetch_array($query))
{
    echo "
    <table border='0' cellpadding = '0' cellspacing='0' width='500'>
        <tr>
            <td>Ime za Kategorija:</td>
            <td>$row[kategorija]</td>
        </tr>
        <tr>
            <td><a href='$self?akcija=pregled&id=$row[id]'>Pogedni ja Kategorijata</a></td>
        </tr>
        <tr>
            <td><hr /></td>
        </tr>
      </table>
      ";
  }
}
    break;
}
}
//end navigation
//------------------------------------------
?>

[/code]

Share this post


Link to post
Share on other sites
[quote]thank you for help, but now in index.php?akcija=dodaj show blank page ?[/quote]

Im not sure what you think your code does but nowhere does a descision get made about what to do if $_GET['akcija'] == dodaj.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.