SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error on file: extract($row);

    sorry to bother you guys, I need a little help on this............please help me out.

    I have a code below but I am getting this error when i run the file.

    Warning: extract() [function.extract]: First argument should be an array in /home/ldemos/public_html/dhost/hna/profile_update.php on line 12
    line 12 starts from: extract($row);

    PHP Code:

    <?php

    require_once('site_functions.php');
    session_start();
    include(
    "connect.php");
    display_header_member('Update User');
    $id $_GET['id'];

    $qProfile "SELECT * FROM user WHERE id='$id'  ";
    $rsProfile mysql_query($qProfile);
    $row mysql_fetch_array($rsProfile);
    extract($row);                               //starts line 12
    $username stripslashes($username);
    $title stripslashes($title);
    $first_name stripslashes($first_name);
    $last_name stripslashes($last_name);
    $email stripslashes($email);
    $company stripslashes($company);
    $phone stripslashes($phone);
    $fax stripslashes($fax);
    $website stripslashes($website);
    $gender stripslashes($gender);
    $zip_code stripslashes($zip_code);
    $country stripslashes($country);
    $dob stripslashes($dob);
    $password stripslashes($password);
    $newsletter stripslashes($newsletter);
    $address stripslashes($address);
    $position stripslashes($position);
    $joindate stripslashes($joindate);

    mysql_close();


    ?>
    <form id="updated_user" action="update.php" method="post" name="updated_user">
    <table width="448" border="0" cellspacing="2" cellpadding="0">
    <tr><td width="150"><div align="right">
    <label for="username">username</label></div>
    </td>
    <td>
    <input id="username" name="username" type="text" size="25" value="<?php echo $username ?>" maxlength="50"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="title">title</label></div>
    </td>
    <td>
    <input id="title" name="title" type="text" size="25" value="<?php echo $title ?>" maxlength="30"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="first_name">first_name</label></div>
    </td>
    <td>
    <input id="first_name" name="first_name" type="text" size="25" value="<?php echo $first_name ?>" maxlength="50"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="last_name">last_name</label></div>
    </td>
    <td>
    <input id="last_name" name="last_name" type="text" size="25" value="<?php echo $last_name ?>" maxlength="50"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="email">email</label></div>
    </td>
    <td>
    <input id="email" name="email" type="text" size="25" value="<?php echo $email ?>" maxlength="50"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="company">company</label></div>
    </td>
    <td>
    <input id="company" name="company" type="text" size="25" value="<?php echo $company ?>" maxlength="50"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="phone">phone</label></div>
    </td>
    <td>
    <input id="phone" name="phone" type="text" size="25" value="<?php echo $phone ?>" maxlength="20"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="fax">fax</label></div>
    </td>
    <td>
    <input id="fax" name="fax" type="text" size="25" value="<?php echo $fax ?>" maxlength="20"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="website">website</label></div>
    </td>
    <td>
    <input id="website" name="website" type="text" size="25" value="<?php echo $website ?>" maxlength="40"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="gender">gender</label></div>
    </td>
    <td>
    <input id="gender" name="gender" type="text" size="25" value="<?php echo $gender ?>" maxlength="20"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="zip_code">zip_code</label></div>
    </td>
    <td>
    <input id="zip_code" name="zip_code" type="text" size="25" value="<?php echo $zip_code ?>" maxlength="20"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="country">country</label></div>
    </td>
    <td>
    <input id="country" name="country" type="text" size="25" value="<?php echo $country ?>" maxlength="30"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="dob">dob</label></div>
    </td>
    <td>
    <input id="dob" name="dob" type="text" size="25" value="<?php echo $dob ?>" maxlength="30"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="password">password</label></div>
    </td>
    <td>
    <input id="password" name="password" type="text" size="25" value="<?php echo $password ?>" maxlength="20"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="newsletter">newsletter</label></div>
    </td>
    <td>
    <input id="newsletter" name="newsletter" type="text" size="25" value="<?php echo $newsletter ?>" maxlength="20"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="address">address</label></div>
    </td>
    <td>
    <textarea id="address" name="address" rows="4" cols="40"><?php echo $address ?></textarea></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="position">position</label></div>
    </td>
    <td>
    <input id="position" name="position" type="text" size="25" value="<?php echo $position ?>" maxlength="30"></td>
    </tr>
    <tr><td width="150"><div align="right">
    <label for="joindate">joindate</label></div>
    </td>
    <td>
    <input id="joindate" name="joindate" type="text" size="25" value="<?php echo $joindate ?>" maxlength="30"></td>
    </tr>
    <tr>
    <td width="150"></td>
    <td><input type="submit" name="Submit" value="Update"><input type="hidden" name="id" value="<?php echo $id ?>"></td>
    </tr>
    </table>
    </form>

    <style type="text/css">
    <!--
    .footer1 {color: #FF6600}
    .footer2 {color: #000099}
    -->
    </style>
    <hr align="left" width="745" color="footer2" class="footer2">
    <table width="745" border="0">
      <tr>
        <td width="566"><span class="footer1">Copyright 
      2007 Allways System. All Rights Reserved. </span></td>
        <td width="169"><span class="footer2"><a href="index.php">Home</a></span> | <span class="footer2"><a href="contact_form.php">Contact</a></span>  | <span class="footer2"><a href="help.php">Help</a></span>  | <span class="footer2"><a href="privacy.php">Privacy</a></span> </td>
      </tr>
    </table>

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure that your query returning the results or working fine? Use mysql_error() to know the problem

    PHP Code:
    $rsProfile mysql_query($qProfile) or die("error in query: ".mysql_error()); 
    It will display the error if any.

    Use mysql_num_rows() to see how many rows your query returns.

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you do realize that you're using WAY too much code there, right?
    Code php:
    foreach ($row as $name => $value) {
    printf('<tr><td width="150"><div align="right">
    <label for="%1$s">%1$s</label></div>
    </td>
    <td>
    <input id="%1$s" name="%1$s" type="text" size="25" value="%2$s" maxlength="30"></td>
    </tr>', $name, $value);
    }
    and why are you using stripslashes()? if you are using addslashes() or mysql_real_escape_string() properly, then you don't need stripslashes().

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [QUOTE=longneck;3478317]QUOTE]

    sorry to disturb you again, can you please explain me where should i put this and how it looks like from the above code, since I am a beginner of php and mysql, you help would be really appreciated.

    Thanks again !!

  5. #5
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well, my code was only an example because it doesn't fully replicate the behavior of your application. all it does is look through all of the columns in $row and create an input control for it. you can do that instead of typing out each of them individually.


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
  •