Results 1 to 7 of 7

Thread: mysql error

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    mysql error

    PHP Code:
     $query="SELECT * FROM clients WHERE username='$username'";
            
    $result=mysql_query($query);
            
    $num=mysql_numrows($result);
            
            
    $i=0;
            
            while(
    $i $num
            {
            
    $msg=mysql_result($result,$i,"msg");
            
            echo 
    $msg;
            
            ++
    $i
            

    anyone see any problems? i am connected to the DB

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resolved

    never mind fixed it

    PHP Code:
            $query="SELECT * FROM clients WHERE username='$username'";
            
    $result=mysql_query($query);
            
    $num=mysql_num_rows($result);
            
            
    $cur=0;
            
            while(
    $num $cur
            {
            
            
    $row=mysql_fetch_array($result);
            
            
    $themsg $row["adminmsg"];
      
            echo 
    $themsg;
            
            
    $cur++;
            } 

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    You are not still using that horrible tutorial are you??
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    thought not but i printed both guides out and they kind of got mixed up, i found the right one in the end,

    while i'm here

    ok i'm trying to pass a few varibles to another page

    PHP Code:

           $location
    ="\display.php?r=.'$result'.&n=.'$num'."
            
            
    header("Location: $location"); 
    i will then use the get method to extract these varibles from the url,

    is this the bets way to d it? if so how would i fix it? if not what is the best way to go about it?

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Using the query string is but one way of passing varaibles between pages. You can also use cookies an sessions. Using the query string is the safest methods with regards to compatibility, becuase you don't have to worry about whether or not the client supports cookies.

    To pass the variable $result:
    PHP Code:
    $location="display.php?r=$result&n=$num";
                
    header("Location: $location"); 
    You don't need dots if your embedding variables in your string.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    hmm.. thats cool thanks, i might look into sessions though, are these a tough thing to learn?

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    The idea behind sessions in PHP is that they encapsulate the persistance of data through a PHP application. All you need to do is start the sessions with session_start() and put variables into the $_SESSION superglobal array. PHP does the rest.

    If the client supports cookies then it will use a cookie to identify the client. If they do not then you can append the identification to the quwery string of URLS.

    http://uk.php.net/manual/en/ref.session.php

    I have an example of how to use sessions in my signature. But here is an even shorter example:

    page1.php
    PHP Code:
    <?php
    session_start
    ();

    $_SESSION['username'] = $_POST['username'];
    ?>
    <a href="page2.php?<?php echo(SID?>">Next Page</a>
    page2.php
    PHP Code:
    <?php
    session_start
    ();

    echo(
    "Hello {$_SESSION['username']}");
    ?>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width