Page 1 of 1

Hi i need help with php

Posted: Wed Nov 04, 2009 2:14 pm
by Goofan
Hi i got a problem with my code
Im making an online game and i ran into problem:
im trying to get my username to fetch from a specific row (saved_id) and to show the username for the public
plz help me....

"im a newb so plz comment ure code so that i can understand it correctly" :-[

Code: Select all

 
<?php
            include "../login/database.php"; //Fil för databasinställning
            @$id=@$_GET[saved_id];
            @$sql="SELECT * FROM konto"; //sätt upp sql fråga.
            
            @$result=mysql_query(@$sql); //hämtar all info från tabell
                echo "<table border='1'>";
                 
            while(@$row = mysql_fetch_array( @$result )) //hämtar info från tabell.
            {
                    echo "<tr><td>";
                echo @$row[fornamn]."'Where @$id=[saved_id]'  </td><td>".@$row[efternamn]."'Where @$id=[saved_id]. </td>"; //skriver ut innehållet radvis (inom kaninöron = html kod)
                    echo "</tr>";
            }
                echo "</table>";
        ?>
 

Re: Hi i need help with php

Posted: Wed Nov 04, 2009 3:26 pm
by Christopher

Code: Select all

            $id = intval($_GET[saved_id]);
            $sql = "SELECT * FROM konto WHERE id=$id";
You should do some actual error checking rather than suppressing errors.

Re: Hi i need help with php

Posted: Wed Nov 04, 2009 3:43 pm
by Goofan
Yea i know but that is a temperal solution to one problem... the (@)
i still cant get my saved id to show...

Code: Select all

 
 
echo "<table border='1'>";
                 
            while(@$row = mysql_fetch_array( @$result )) //hämtar info från tabell.
            {
                    echo "<tr><td>";
                echo @$row[fornamn]."'Where @$id=[saved_id]'  </td><td>".@$row[efternamn]."'Where @$id=[saved_id]. </td>"; //skriver ut innehållet radvis (inom kaninöron = html kod)
                    echo "</tr>";
            }
                echo "</table>";
 
 
Here im telling it to write the "firstname" and the "lastname" when i add this to my "code" nothing at all comes up
i know it should say "thomas Persson" within a table but as i got it right now nothing shows.

i got a database called ... with a table called konto and within that i got "the saved id" so with that i should get a number and with that number i get what row "the user" is on...



that was my receive page...
this is my sending 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[***] =="1"))//Kollar så att användare finns i databasen och kollar om användaren är ***.
                    {
                        header('Refresh: 0; url=../***/***_***(***).php?saved_id='.$row[saved_id]);//Skickas till angiven sida.
                    }
                if ((@$_POST[user]== @$row[user]) && (@$_POST[password]== @$row[pass]) && (@$row[***] =="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.
            
}
?>
 
the *** stands for secret ^^
Here u can see that im sending the saved_id

Code: Select all

 
header('Refresh: 0; url=../menu_main(menu).php?saved_id='.$row[saved_id]) // here u can see im sending the saved_id
 

Re: Hi i need help with php

Posted: Wed Nov 04, 2009 7:15 pm
by califdon
What arborint was telling you is that you cannot learn what the problem is, when you suppress error messages. That's what they are for, to help you determine what is going wrong. By suppressing the errors, you make it impossible to debug your script. Remove the @'s and see what errors are reported, and you will probably have your answer.