+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP problem (please help soon!)

  1. #1
    igames is offline x10Hosting Member igames is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    34

    PHP problem (please help soon!)

    hey i have some php expirence but not that much and im wondering if someone could help me here. the problem is that i need to display a user information so he/she can edit it if needed and ect. so i am trying to call a session in a mysql query. i dont know if this will work (so far it hasnt) and i need help. so here is the code

    PHP Code:
    $query="SELECT * FROM users WHERE username = "$_SESSION['myusername'] ."; ";

    $result=mysql_query($query) or die(mysql_error());

    $num=mysql_numrows($result);

    echo 
    "<b><center>Account Info</center></b><br><br>";

    $i=0;
    while (
    $i $num) {

    $name=mysql_result($result,$i,"name");
    $username=mysql_result($result,$i,"username");
    $email=mysql_result($result,$i,"email");

    echo 
    "Name:<br><b>$name</b><br><br>Username:<br>$username<br><br>E-Mail:<br>$email<br><hr><br>";

    $i++;
    }
    ?> 

    anyone tell me what im doing wrong?
    thanks in advance

    i forgot that i wanted to tell you i have the connect to the database but i just didnt feel like posting it
    Edit:
    i am sorry that i have posted this form but i have now figured it out.
    Last edited by igames; 10-14-2008 at 06:52 PM. Reason: Automerged Doublepost

  2. #2
    Aravinthan is offline x10Hosting Member Aravinthan is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    68

    Re: PHP problem (please help soon!)

    Quote Originally Posted by igames View Post
    hey i have some php expirence but not that much and im wondering if someone could help me here. the problem is that i need to display a user information so he/she can edit it if needed and ect. so i am trying to call a session in a mysql query. i dont know if this will work (so far it hasnt) and i need help. so here is the code

    PHP Code:
    $query="SELECT * FROM users WHERE username = "$_SESSION['myusername'] ."; ";
     
    $result=mysql_query($query) or die(mysql_error());
     
    $num=mysql_numrows($result);
     
    echo 
    "<b><center>Account Info</center></b><br><br>";
     
    $i=0;
    while (
    $i $num) {
     
    $name=mysql_result($result,$i,"name");
    $username=mysql_result($result,$i,"username");
    $email=mysql_result($result,$i,"email");
     
    echo 
    "Name:<br><b>$name</b><br><br>Username:<br>$username<br><br>E-Mail:<br>$email<br><hr><br>";
     
    $i++;
    }
    ?> 

    anyone tell me what im doing wrong?
    thanks in advance

    i forgot that i wanted to tell you i have the connect to the database but i just didnt feel like posting it
    Edit:
    i am sorry that i have posted this form but i have now figured it out.
    Is it a only a part of the whole code?
    Because you need to give the username, password and localhost. If its a part, you dont need use the session:
    mysql_query("SELECT * FROM users where username="myusername" )
    or die("error querying database");
    It should work...... because i need the whole part

  3. #3
    Myokram is offline x10Hosting Member Myokram is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    30

    Re: PHP problem (please help soon!)

    If $_SESSION['myusername'] is a string value, then you need to 'single-quote' it:

    PHP Code:
    $query="SELECT * FROM users WHERE username = '"$_SESSION['myusername'] ."'"
    Anyway, does it display any error message? What's wrong with your code?

    Greetings.

  4. #4
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: PHP problem (please help soon!)

    Reply to the thread saying you've fixed it. It's very easy to miss that last line.

    Also - how did you fix it?
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

+ Reply to Thread

Similar Threads

  1. Replies: 3
    Last Post: 03-10-2008, 12:22 PM
  2. problem in php mail function and smtp
    By idrees in forum Free Hosting
    Replies: 2
    Last Post: 02-08-2008, 05:16 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM
  5. php ad code problem
    By sourabhj in forum Free Hosting
    Replies: 7
    Last Post: 08-22-2006, 08:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers