Jump to content

Recommended Posts

Good day Fellow excellent Code Comrades,

Please I am in the middle of creating an edit profile page but when I test run this script, on the html form in the browser, rather than echoing the specific column value, it rather echos

 

this><? echo .$pfno; ?> rather than the actual value stored in the field

<?php
$pfno=$_GET['pfno'];
$result=mysql_query("SELECT (*) FROM user_table WHERE pfno=$pfno");
//$result = mysql_fetch_assoc($select);
$num=mysql_num_rows($result);
mysql_close();

$i=0;
while ($i < $num) {
$amountd=mysql_result($result,$i,"amountd");
$department=mysql_result($result,$i,"department");
$email=mysql_result($result,$i,"email");
$fname=mysql_result($result,$i,"fname");
$oname=mysql_result($result,$i,"oname");
$lname=mysql_result($result,$i,"lname");
$lga=mysql_result($result,$i,"lga");
$marital=mysql_result($result,$i,"marital");
$Nationalty=mysql_result($result,$i,"Nationalty");
$pfno=mysql_result($result,$i,"pfno");
$residentialadd=mysql_result($result,$i,"residentialadd");
$sex=mysql_result($result,$i,"sex");
$soorigin=mysql_result($result,$i,"soorigin");
$telno=mysql_result($result,$i,"telno");
//Space For Code

++$i;
}
?>
<form action='Edit_Profile.php' method='post' enctype='multipart/form-data' name='register'>
  <table width='28%' border='0' align='center' cellpadding='0' cellspacing='0'>
    <tr>
      <td colspan='2'><div align='center'>
        <p><font size="2" face="verdana">Edit your Profile</font></p>
        </div></td>
    </tr>
    <tr>
      <td width='31%'> </td>
      <td width='69%'> </td>
    </tr>
    <tr>
      <td colspan='2'><hr></td>
    </tr>
    <tr>
      <td height='26'><font size='2' face='verdana'>PF NO.</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='pfno' value="<? echo .$pfno; ?>">
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>FIRST NAME</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='fname' value= "<? echo $fname; ?>" >
        </font></td>
    </tr>
   <tr>
      <td height='25'><font size='2' face='verdana'>OTHER NAMES</font><font size='2' face='verdana'></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='oname' value= "<? echo $oname; ?>" >
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>LAST NAME</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='lname' value="<? echo $lname; ?>" >
        </font></td>
    </tr>
   <tr>
      <td height='25'><font size='2' face='verdana'>STATE OF ORIGIN</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='soorigin' value="<? echo $soorigin; ?>" >
        </font></td>
    </tr>
   <tr>
      <td height='25'><font size='2' face='verdana'>LOCAL GOVERNMENT</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='lga' value="<? echo $lga; ?>" >
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>NATIONALITY</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='Nationalty' value="<? echo $Nationalty; ?>" >
        </font></td>
    </tr>
    <tr>
      <td height='26'><font size='2' face='verdana'>Email address</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='email' value="<? echo $email; ?>" >
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>RESIDENTIAL ADDRESS</font></td>
      <td><font size='2' face='verdana'>
        <input type='textarea' name='residentialadd' value="<? echo $residentialadd; ?>"  >
      </font></td>
    </tr>
    <tr>
    <td height='25'><font size='2' face='verdana'>TELEPHONE NUMBER</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='residentialadd' value="<? echo $telno; ?>" >
        </font></td>
    </tr>
    <tr> 
      <td height='25'><font size='2' face='verdana'>DEPARTMENT</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='department'value="<? echo $department; ?>""  >
      </font></td>
    </tr>
    <tr>
    <td height='25'><font size='2' face='verdana'>MARITAL STATUS</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='marital' value="<? echo $marital; ?>" >
        </font></td>
    </tr>
    <tr>
    <td height='25'><font size='2' face='verdana'>SEX</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='sex' value="<? echo $sex; ?>" >
        </font></td>
    </tr>
    <tr> 
   <td height='25'><font size='2' face='verdana'>AMOUNT DEDUCTIBLE</font></td>
      <td><font size='2' face='verdana'>
        <input type='text' name='amountd' value="<? echo $amountd; ?>"" >
      </font></td>
    </tr>
    <tr>
      <td> </td>
      <td><font size='2' face='verdana'>
        <input type='submit' name='Submit' value='Update'>
        </font></td>
    </tr>
    <tr>
      <td colspan='2'><hr></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
    </tr>
  </table>
</form><div align='center'><font size='1' face='verdana'><a href='Admin_Login.php'>Back to login page</a></font></div>
<td colspan='2'><div align='center'><font size='1' face='verdana'>TM</font></div></td>
<td colspan='2'> </td>
<?php
$amountd=$_POST['amountd'];
$department=$_POST['department'];
$email=$_POST['email'];
$fname=$_POST['fname'];
$lga=$_POST['lga'];
$lname=$_POST['lname'];
$Nationalty=$_POST['Nationalty'];
$oname=$_POST['oname'];
$residentialadd=$_POST['residentialadd'];
$soorigin=$_POST['soorigin'];
$telno=$_POST['telno'];



$query = "UPDATE contacts SET amountd = '$amountd', department = '$department', email = '$email', fname = '$fname', lga = '$lga', lname = '$lname', marital = '$marital', Nationalty=$Nationalty, oname=$oname, residentialadd=$residentialadd, soorigin=$soorigin,telno=$telno, WHERE pfno = '$pfno'";
mysql_query($query);
echo "Record Updated";
mysql_close();
?>

 

Besides, this ugly message

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in line 23"

keeps coming up.

=>line 23 = $num=mysql_num_rows($result);

 

These are the 2 issues I'm battling with.. please I need your effective pointers..

Link to comment
https://forums.phpfreaks.com/topic/169588-sql-update-member-fields/
Share on other sites

use <?php instead of <?

 

I did as you can see but its still not going through:

 

Check out:

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

$pfno=$_GET['id'];
$row=mysql_query("SELECT (*) FROM user_table WHERE id=$id");
//$result = mysql_fetch_assoc($select);
$num=mysql_fetch_array($row);
//mysql_close();

$i=0;
while ($i < $num) {
$amountd=mysql_result($result,$i,"amountd");
$department=mysql_result($result,$i,"department");
$email=mysql_result($result,$i,"email");
$fname=mysql_result($result,$i,"fname");
$oname=mysql_result($result,$i,"oname");
$lname=mysql_result($result,$i,"lname");
$lga=mysql_result($result,$i,"lga");
$marital=mysql_result($result,$i,"marital");
$Nationalty=mysql_result($result,$i,"Nationalty");
$pfno=mysql_result($result,$i,"pfno");
$residentialadd=mysql_result($result,$i,"residentialadd");
$sex=mysql_result($result,$i,"sex");
$soorigin=mysql_result($result,$i,"soorigin");
$telno=mysql_result($result,$i,"telno");
//Space For Code

$query = ("UPDATE user_table SET amountd = '$amountd', department = '$department', email = '$email', fname = '$fname', lga = '$lga', lname = '$lname',marital='$marital', Nationalty='$Nationalty',oname='$oname', residentialadd='$residentialadd', soorigin='$soorigin',telno='$telno', WHERE pfno = '$pfno'");
mysql_query($query);
echo //"Record Updated";
mysql_close();

++$i;
}

$amountd=$_POST['amountd'];
$department=$_POST['department'];
$email=$_POST['email'];
$fname=$_POST['fname'];
$lga=$_POST['lga'];
$lname=$_POST['lname'];
$marital=$_POST['marital'];
$Nationalty=$_POST['Nationalty'];
$oname=$_POST['oname'];
$residentialadd=$_POST['residentialadd'];
$soorigin=$_POST['soorigin'];
$telno=$_POST['telno'];

?>
<form action='Edit_Profile.php' method='post' enctype='multipart/form-data' name='register'>
  <table width='28%' border='0' align='center' cellpadding='0' cellspacing='0'>
    <tr>
      <td colspan='2'><div align='center'>
        <p><font size="2" face="verdana">Edit your Profile</font></p>
        </div></td>
    </tr>
    <tr>
      <td width='31%'> </td>
      <td width='69%'> </td>
    </tr>
    <tr>
      <td colspan='2'><hr></td>
    </tr>
    <tr>
      <td height='26'><font size='2' face='verdana'>PF NO.</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['pfno'] ?>">        
     </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>FIRST NAME</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['fname'] ?>">        
       </font></td>
    </tr>
   <tr>
      <td height='25'><font size='2' face='verdana'>OTHER NAMES</font><font size='2' face='verdana'></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['oname'] ?>">        
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>LAST NAME</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['lname'] ?>">        
        </font></td>
    </tr>
   <tr>
      <td height='25'><font size='2' face='verdana'>STATE OF ORIGIN</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['soorigin'] ?>">        
        </font></td>
    </tr>
   <tr>
      <td height='25'><font size='2' face='verdana'>LOCAL GOVERNMENT</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['lga'] ?>">        
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>NATIONALITY</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['Nationalty'] ?>">        
        </font></td>
    </tr>
    <tr>
      <td height='26'><font size='2' face='verdana'>Email address</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['email'] ?>">        
        </font></td>
    </tr>
    <tr>
      <td height='25'><font size='2' face='verdana'>RESIDENTIAL ADDRESS</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['residentialadd'] ?>">        
      </font></td>
    </tr>
    <tr>
    <td height='25'><font size='2' face='verdana'>TELEPHONE NUMBER</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['telno'] ?>">        
        </font></td>
    </tr>
    <tr> 
      <td height='25'><font size='2' face='verdana'>DEPARTMENT</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['department'] ?>">        
      </font></td>
    </tr>
    <tr>
    <td height='25'><font size='2' face='verdana'>MARITAL STATUS</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['marital'] ?>">        
        </font></td>
    </tr>
    <tr>
    <td height='25'><font size='2' face='verdana'>SEX</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['sex'] ?>">        
        </font></td>
    </tr>
    <tr> 
   <td height='25'><font size='2' face='verdana'>AMOUNT DEDUCTIBLE</font></td>
      <td><font size='2' face='verdana'>
     <input name="username" type="text" value="<?php echo $row['amountd'] ?>">        
      </font></td>
    </tr>
    <tr>
      <td> </td>
      <td><font size='2' face='verdana'>
        <input type='submit' name='Submit' value='Update'>
        </font></td>
    </tr>
    <tr>
      <td colspan='2'><hr></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
    </tr>
  </table>
</form><div align='center'><font size='1' face='verdana'><a href='Admin_Login.php'>Back to login page</a></font></div>
<td colspan='2'><div align='center'><font size='1' face='verdana'>TM</font></div></td>
<td colspan='2'> </td>


</body>
</html>

 

Is an edit_profile code, which is meant to display existing member information from the database and after editing the info  update a table. But its not showing the exisitng data much less updating.

Besides, its morelike show at the top of the browser:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in line24="$num=mysql_fetch_array($row);"

 

Please any valid pointers would be appreciated. Thanks...

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.