Bader H Al Rayyes
Bader H Al Rayyes

Reputation: 522

Edit mysql record db with php

i am trying to edit a mysql database record , there is seem to be an issue with my code

here is the code from page editVisitor.php

    <?
    while($row=mysql_fetch_array($result)) 
    { 
    ?>
    <?
    $message=stripslashes($row["userUserName"]);
    $msg_id=$row["useId"];  
    ?>

      <li><a href="editUserDetails.php?edit=<?php echo $msg_id; ?>" >
<?php echo $message; ?></a>   <a href="#" id="<?php echo $msg_id; ?>" class="delete_button">X</a></li>


    <?php
    }
    ?>

this is my code in editUserDetails.php that open new page with all fields to update the record :

<?php

$connection= mysql_pconnect("localhost","root","123") or die (mysql_error());
            $db= mysql_select_db("reservebox",$connection) or die (mysql_error());


$selectdata="SELECT * FROM user WHERE useId =" . $edit . "";
mysql_query($selectdata);

$row = mysql_fetch_array($selectdata);


?>

//html form and table code



<input type="text" name="FirstName" id="FirstName" value="<? echo $row['userUserName']; ?>"/>

the editVisitorDetails.php doesn't show any data and i continue get this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in    

Upvotes: 0

Views: 147

Answers (1)

Mert Emir
Mert Emir

Reputation: 691

$selectdata="SELECT * FROM user WHERE useId =" . $edit . "";
$query=mysql_query($selectdata);

$row = mysql_fetch_array($query);

Upvotes: 2

Related Questions