Gå til innhold

Problem med script =(


Anbefalte innlegg

Heisann, jeg får en fin feilmelding på scriptet mitt. Skjønner ikke hva jeg har gjort feil.

 

Erroren er den klassiske:

 

Parse error: syntax error, unexpected T_ELSE in /mounted-storage/home20a/sub001/sc20063-GJYD/ru.net/link/add.php on line 106

 

Klikk for å se/fjerne innholdet nedenfor
100.	    	     $sql3 = "INSERT INTO link (link_id, link_title, link_url, link_desc, link_posted, user_id, cat_id) 	VALUES ('$iddd','$name','$url','$desc','$now','$userID','1')";
101.	    	     $result3 = mysql_query($sql3) or die(mysql_error());
102.			 }
103.		 }
104.      }
105.	  else
106.      {
107.	     // Password is incorrect
108.	     header ( "Location: index.php");

 

<?php

// SQL connection
include "config.php";

// First; check if user is loged in or not. If loged in: feel free to add a link, else you will be located to the loginpage
if ( $_SESSION['in'] == TRUE )
{
  $sql = "SELECT username FROM user WHERE username = '$_SESSION[username]'";
  $result = mysql_query($sql) or die(mysql_error());
  $num = mysql_num_rows($result);
  if ($num > 0 ) // login name was found
  {
     $sql2 = "SELECT username, user_password, FROM user WHERE username = '$_SESSION[username]' AND user_password = '$_SESSION[password]'";
     $result2 = mysql_query($sql2) or die(mysql_error());
     $num2 = mysql_num_rows($result2);
     if ($num2 > 0) // password is correct
     {
     // User is logged in. He can now add links to the database
        if (!isset($_POST['add']))
        {
            echo "<table width='29%' border='0' align='center' >";
            echo "<tr>";
            echo "<td width='20%' height='25'>";
            echo "<form action='add.php' method='post'>";
            echo "Name: </td><td width='70%'><input type='text' name='name' value='" . $_POST['name'] . "'></td>";
            echo "</tr>";
            echo "<tr>";
            echo "<td width='20%' height='25'>";
            echo "URL: </td><td width='70%'><input type='text' name='url' value='" . $_POST['url'] . "'></td>";
            echo "</tr>";
            echo "<tr>";
            echo "<td width='20%' height='25'>";
            echo "Beskrivelse </td><td width='70%'><input type='text' name='desc' value='" . $_POST['desc'] . "'></td>";
            echo "</tr>";
            echo "<tr>
            <td width='20%' height='25'>";
            echo "</td><td width='70%'>";
            echo "<input type='submit' name='preview' value='Forhåndsvis'></td></form>";
            echo "</tr>";
            echo "</table>";
        }
	 else
	 {
	     // User has posted a link
		 if ($_POST['name'] == '')
		 {
		     echo "Du må fylle ut en tittel";
			 unset ($_POST['add']);
			 include "add.php";
		 }

		 if ($_POST['url'] == '')
		 {
		     echo "Du må fylle ut en url";
			 unset ($_POST['add']);
			 include "add.php";
		 }

		 if ($_POST['desc'] == '')
		 {
		     echo "Du må fylle ut en beskrivelse";
			 unset ($_POST['add']);
			 include "add.php";
		 }
		 else
		 {
    		 // All the fields is filled and the link will be stored in the database

    		 //Create the date
    	     $now = date("M d Y - H:s");

    		 // Get the highest ID from the database
    		 $idget = "SELECT max(id) FROM link"; $resultt=mysql_query($idget) or die(mysql_error());
    		 while ($roww=mysql_fetch_assoc($resultt))
    		 {
    		    $idd = $roww['id'];
    		 }
    		 mysql_free_result($resultt);

    		 // Add one to get a new ID
    		 $iddd = $idd + 1;

    		 $getuserid = "SELECT username, user_id FROM user WHERE username = '$_SESSION[username]'";
    		 $result4 = mysql_query($getuserid) or die(mysql_error());
    		 while ($rowww=mysql_fetch_assoc($result4))
    		 {
    		     $rowww['id'] = $userID;
    		 {
    		 mysql_free_result($result);

    		 // Getting the post info into normal vars for database use
    		 $_POST['name'] = $name;
    		 $_POST['url'] = $url;
    		 $_POST['desc'] = $desc;

    		 // Insert all the info into the database
    	     $sql3 = "INSERT INTO link (link_id, link_title, link_url, link_desc, link_posted, user_id, cat_id) 	VALUES ('$iddd','$name','$url','$desc','$now','$userID','1')";
    	     $result3 = mysql_query($sql3) or die(mysql_error());
		 }
	 }
     }
  else
     {
     // Password is incorrect
     header ( "Location: index.php");
  }
  }
  else
  {
     // Username is incorrect
     header ( "Location: index.php");
  }
}
else
{
   // Not logged in at all
   header ( "Location: index.php");
}
?>

Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...