Page 2 of 2

Re: You have an error in your SQL syntax; problem!!! =(

Posted: Thu Nov 05, 2009 1:46 pm
by Goofan
first sending code... here im sending the code to the reciever code nr1 also called transferer of data page

Code: Select all

 
<?php
include "database.php";//Fil för databasinställning.
 
if (@$_POST["submit"])//Kollar om knappen SUBMIT använts.
{
$sql="SELECT * FROM konto";//Ta allt från databas tabellen: "konto".
 
    $result = mysql_query($sql) or die(mysql_error(FAIL));//Välj all info i tabell.
        while($row = mysql_fetch_array( $result ))//Hämtar info från tabell.
            {
                if ((@$_POST[user]== @$row[user]) && (@$_POST[password]== @$row[pass]) && (@$row[admin] =="1"))//Kollar så att användare finns i databasen och kollar om användaren är admin.
                    {
                        header('Refresh: 0; url=../admin/admin_menu(main).php?saved_id='.$row[saved_id]);//Skickas till angiven sida.
                    }
                if ((@$_POST[user]== @$row[user]) && (@$_POST[password]== @$row[pass]) && (@$row[admin] =="0"))//Kollar så att användare finns i databasen och kollar om användaren är admin.
                    {
                        header('Refresh: 0; url=../menu_main(menu).php?saved_id='.$row[saved_id]);//Skickas till angiven sida.
                    }       
            }
        exit;//Lämnar loop.
            header("Location: login.php");//Skickas till angiven sida efter en viss tid.
            
}
?>
 
when i log on i get a number following me "saved_id" so that i know what row the user "is"




recieving page nr1 also called transferer of data page

Code: Select all

 
<script type="text/javascript">
parent.main.location.href = "sidor/admin_overview.php?saved_id=<?php echo $_GET['saved_id'] ?>"
parent.menu.location.href = "admin_menu.php?saved_id=<?php echo $_GET['saved_id'] ?>"
</script>
 
here im only transfering the data further to the 2 new windows opening "target opening"





recieving page nr 2 Final recieving page

Code: Select all

 
<?php
include "../login/database.php";        //page to where the database setting is, including this file into the php script of wichh is below it
$id =(isset($_GET['saved_id'])) ? $_GET['saved_id'] : false;        //putting the information within saved_id of witch i got from the previous page and putted it into $id
 
     $sql="SELECT * FROM konto WHERE saved_id=$id";     //selecting all from DB "Konto" where saved_id is the same as in the array $id
 
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tall. //hämtar all info från tabell
 
                 
while($row = mysql_fetch_array( $result )) //hämtar info från tabell.
{
    $user=$row['user'];
}
?>
 

then further down i got this code only to write out the information collected in the other php script

Code: Select all

 
<center>name: <?php echo $user['user'] ?><br></center>
 
its here that i can see its only one letter that is coming out from the database
instead of the 3 letters i got in there


-Thomas


hope it helps alittle

Re: You have an error in your SQL syntax; problem!!! =(

Posted: Thu Nov 05, 2009 1:49 pm
by Goofan
thanks that made it correct... i had forgotten a ; at the end of //further down text and thanks alot now i can work on =)

Re: You have an error in your SQL syntax; problem!!! =(

Posted: Thu Nov 05, 2009 1:49 pm
by Goofan
too easy to spot =)

Re: You have an error in your SQL syntax; problem!!! =(

Posted: Thu Nov 05, 2009 1:50 pm
by Goofan
well remember me so that i can help u in the future if u get any problems ;)