SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form not displaying within the php

    Hi guys having issues with my update script, this is the error I keep getting can anyone help


    I have a blank page every time I access it. Why is the form not showing

    Msny thanks in advance for your help


    update.php


    <?
    $dbhost = 'localhost';
    $dbuser = 'notexper_two';
    $dbpass = 'three';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

    $dbname = 'notexper_one';
    mysql_select_db($dbname);
    $query="SELECT * FROM members WHERE id='$user_id'";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    mysql_close();

    $i=0;
    while ($i < $num) {
    $firstname=mysql_result($result,$i,"firstname");
    $lastname=mysql_result($result,$i,"lastname");


    ?>

    <form action="updated.php">
    <input type="hidden" name="ud_id" value="<? echo "$user_id"; ?>">
    First Name: <input type="text" name="firstname" value="<? echo "$firstname"?>"><br>
    Last Name: <input type="text" name="lastname" value="<? echo "$lastname"?>"><br>

    <input type="Submit" value="Update">
    </form>

    <?
    ++$i;
    }
    ?>

    updated.php


    <?
    $dbhost = 'localhost';
    $dbuser = 'notexper_two';
    $dbpass = 'three';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

    $dbname = 'notexper_one';
    mysql_select_db($dbname);
    $query="UPDATE contacts SET first='$ud_first', last='$ud_last' WHERE id='$user_id'";
    mysql_select_db($database) or die( "Unable to select database");
    mysql_query($query);
    echo "Record Updated";
    mysql_close();
    ?>
    Last edited by wazo; May 12, 2007 at 10:50.

  2. #2
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the error_reporting and display_errors turned on?

  3. #3
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe it's upset because you put mysql_numrows() instead of mysql_num_rows()? When developing you should use a proper error reporting level that shows warnings and errors at least.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change update.php to:
    PHP Code:
    <?php
    // Show us the damn errors.
    error_reporting(E_ALL);
    ini_set('display_errors','true');

    $dbhost 'localhost';
    $dbuser 'notexper_two';
    $dbpass 'three';

    $conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to mysql');

    $dbname 'notexper_one';
    mysql_select_db($dbname);
    $query="SELECT * FROM members WHERE id='$user_id'";
    $result=mysql_query($query);
    $num=mysql_num_rows($result);
    mysql_close();
    $i=0;
    while (
    $i $num) {
    $firstname=mysql_result($result,$i,"firstname");
    $lastname=mysql_result($result,$i,"lastname");
    ?>
    <form action="updated.php">
    <input type="hidden" name="ud_id" value="<?php echo $user_id?>">
    First Name: <input type="text" name="firstname" value="<?php echo $firstname?>"><br>
    Last Name: <input type="text" name="lastname" value="<?php echo $lastname?>"><br>
    <input type="Submit" value="Update">
    </form>
    <?php
    $i 
    $i 1;
    }
    ?>

  5. #5
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have done that and there is no errors still nothing shows

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Location
    Tampa, Fl
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't used that form to retrieve data from a database before, but is that While loop necessary there? Can't you just assign those result to the variable without the loop?


Bookmarks

Posting Permissions

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