PHP

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Select record by ID

    3 answers - 1758 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Before I ask my next question I just wanted to thank you all for being in
    this mailing community and sharing your knowledge. Its communitys like this
    that make life easier for all of us. enough with the mushy stuff
    Im trying to display one record at a time by ID. Well im getting a blank
    page. Ive looked over my code and tried 20 different ways to get it to work
    to no avail. So any pointers on what Im doing wrong would be great. here is
    the code im working with so far.
    <?php
    include("db.php");
    $result = mysql_query("SELECT * FRM inf_member WHERE
    user_id='$user_id' ");
    while($myrow = mysql_fetch_assoc($result))
    {
    echo "<b>";
    echo $myrow['user_name'];
    echo "</b>";
    echo $myrow['rank'];
    echo "</b>";
    echo $myrow['country'];
    echo "</b>";
    echo $myrow['email'];
    echo "</b>";
    echo $myrow['quote'];
    echo "</b>";
    echo $myrow['config'];
    echo "</b>";
    echo $myrow['map'];
    echo "</b>";
    echo $myrow['gun'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";
    echo $myrow['cpu'];
    echo "</b>";
    echo $myrow['ram'];
    echo "</b>";
    echo $myrow['video'];
    echo "</b>";
    echo $myrow['sound'];
    echo "</b>";
    echo $myrow['monitor'];
    echo "</b>";
    echo $myrow['mouse'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";
    }
    ?>
    FREE online classifieds from Windows Live Expo buy and sell with people
    you know
  • No.1 | | 2202 bytes | |

    The first thing that I probably do is to check for possible errors from
    DB:

    $result = mysql_query("SELECT * FRM inf_member WHERE
    user_id='$user_id' ");
    if ( ! $result ) {
    die ("Could not perform query $query: ".mysql_error()."\n");
    }

    Regards,

    dom, 2007-01-28 at 18:21 -0500, nitrox . wrote:
    Before I ask my next question I just wanted to thank you all for being in
    this mailing community and sharing your knowledge. Its communitys like this
    that make life easier for all of us. enough with the mushy stuff

    Im trying to display one record at a time by ID. Well im getting a blank
    page. Ive looked over my code and tried 20 different ways to get it to work
    to no avail. So any pointers on what Im doing wrong would be great. here is
    the code im working with so far.

    <?php
    include("db.php");

    $result = mysql_query("SELECT * FRM inf_member WHERE
    user_id='$user_id' ");
    while($myrow = mysql_fetch_assoc($result))
    {
    echo "<b>";
    echo $myrow['user_name'];
    echo "</b>";
    echo $myrow['rank'];
    echo "</b>";
    echo $myrow['country'];
    echo "</b>";
    echo $myrow['email'];
    echo "</b>";
    echo $myrow['quote'];
    echo "</b>";
    echo $myrow['config'];
    echo "</b>";
    echo $myrow['map'];
    echo "</b>";
    echo $myrow['gun'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";
    echo $myrow['cpu'];
    echo "</b>";
    echo $myrow['ram'];
    echo "</b>";
    echo $myrow['video'];
    echo "</b>";
    echo $myrow['sound'];
    echo "</b>";
    echo $myrow['monitor'];
    echo "</b>";
    echo $myrow['mouse'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";

    }
    ?>

    FREE online classifieds from Windows Live Expo buy and sell with people
    you know

    PGP SIGNATURE
    Version: GnuPG v1.4.3 (GNU/Linux)

    Bt0W6vmQEvyy5Mp0ISI9i/Y=
    =TFf0
    PGP SIGNATURE
  • No.2 | | 2720 bytes | |

    !, Better this one:

    $query = "SELECT inf_member WHERE user_id='$user_id' ";
    $result = mysql_query($query);
    if ( ! $result ) {
    die ("Could not perform query $query: ".mysql_error()."\n");
    }

    I did copy and paste from my own code and you've not $query defined on
    your one. I prefer to store first the query on a string to show it
    complete if there's an error late, because it may show also the point.

    lun, 2007-01-29 at 00:39 +0100, Francisco M. Marzoa Alonso wrote:
    The first thing that I probably do is to check for possible errors from
    DB:

    $result = mysql_query("SELECT inf_member WHERE
    user_id='$user_id' ");
    if ( ! $result ) {
    die ("Could not perform query $query: ".mysql_error()."\n");
    }

    Regards,

    dom, 2007-01-28 at 18:21 -0500, nitrox . wrote:
    Before I ask my next question I just wanted to thank you all for being in
    this mailing community and sharing your knowledge. Its communitys like this
    that make life easier for all of us. enough with the mushy stuff

    Im trying to display one record at a time by ID. Well im getting a blank
    page. Ive looked over my code and tried 20 different ways to get it to work
    to no avail. So any pointers on what Im doing wrong would be great. here is
    the code im working with so far.

    <?php
    include("db.php");

    $result = mysql_query("SELECT * FRM inf_member WHERE
    user_id='$user_id' ");
    while($myrow = mysql_fetch_assoc($result))
    {
    echo "<b>";
    echo $myrow['user_name'];
    echo "</b>";
    echo $myrow['rank'];
    echo "</b>";
    echo $myrow['country'];
    echo "</b>";
    echo $myrow['email'];
    echo "</b>";
    echo $myrow['quote'];
    echo "</b>";
    echo $myrow['config'];
    echo "</b>";
    echo $myrow['map'];
    echo "</b>";
    echo $myrow['gun'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";
    echo $myrow['cpu'];
    echo "</b>";
    echo $myrow['ram'];
    echo "</b>";
    echo $myrow['video'];
    echo "</b>";
    echo $myrow['sound'];
    echo "</b>";
    echo $myrow['monitor'];
    echo "</b>";
    echo $myrow['mouse'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";

    }
    ?>

    FREE online classifieds from Windows Live Expo buy and sell with people
    you know

    PGP SIGNATURE
    Version: GnuPG v1.4.3 (GNU/Linux)

    XUALqxnESSjlZx4MTNsW8=
    =hr4g
    PGP SIGNATURE
  • No.3 | | 2781 bytes | |

    Sun, January 28, 2007 5:21 pm, nitrox . wrote:
    Im trying to display one record at a time by ID. Well im getting a
    blank
    page. Ive looked over my code and tried 20 different ways to get it to
    work
    to no avail. So any pointers on what Im doing wrong would be great.
    here is
    the code im working with so far.

    First, be sure you are using "View Source" in your browser, so that
    something like:

    <unclosed tag will HIDE ALL this content >

    <?php
    include("db.php");

    include is not actually a function, and doesn't need parens, so the
    ()s here are just kinda silly

    $result = mysql_query("SELECT * FRM inf_member WHERE
    user_id='$user_id' ");

    You need *SME* kind of check here on whether your query succeeded.

    The canonical example is:
    $result = mysql_query() or die(mysql_error());

    It would also be wise to get in the habit now of configuring your
    web-server to NT display_errors but to log_errors in your php.ini (or
    in .htaccess with php_value) and then to read your error logs instead
    of your web page.

    The point being to not expose the internal workings of your
    application to the Bad Guys who use such info to make it easier to
    break into your machine.

    Read this over and over until you understand all of it:
    http://phpsec.org

    while($myrow = mysql_fetch_assoc($result))
    {
    echo "<b>";
    echo $myrow['user_name'];
    echo "</b>";
    echo $myrow['rank'];
    echo "</b>";
    echo $myrow['country'];
    echo "</b>";
    echo $myrow['email'];
    echo "</b>";
    echo $myrow['quote'];
    echo "</b>";
    echo $myrow['config'];
    echo "</b>";
    echo $myrow['map'];
    echo "</b>";
    echo $myrow['gun'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";
    echo $myrow['cpu'];
    echo "</b>";
    echo $myrow['ram'];
    echo "</b>";
    echo $myrow['video'];
    echo "</b>";
    echo $myrow['sound'];
    echo "</b>";
    echo $myrow['monitor'];
    echo "</b>";
    echo $myrow['mouse'];
    echo "</b>";
    echo $myrow['brand'];
    echo "</b>";

    Instead of a bunch of echo statements like this, you may want to
    consider the 'heredoc' syntax, or at least fewer echo statements such
    as:
    echo "<b>$myrow[brand]</b><br />\n";

    , you could do like this:
    foreach($myrow as $field =value){
    echo "$field: <b>$value</b><br />\n";
    }
    instead of all those echo statements.

    }
    ?>

Re: Select record by ID


max 4000 letters.
Your nickname that display:
In order to stop the spam: 5 + 5 =
QUESTION ON "PHP"

EMSDN.COM