Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:40:21+00:00 2026-06-12T13:40:21+00:00

I am trying to do something really simple here. All I want to do

  • 0

I am trying to do something really simple here. All I want to do is to update information in MySQL
Here is the code below for the form.

 <?php
 $host=""; // Host name 
 $username=""; // Mysql username 
 $password=""; // Mysql password 
 $db_name=""; // Database name 
 $tbl_name=""; // Table name 

 // Connect to server and select database.
 mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
 mysql_select_db("$db_name")or die("cannot select DB");

 // get value of id that sent from address bar
 $dj=$_GET['dj'];

 // Retrieve data from database 
 $sql="SELECT * FROM $tbl_name WHERE dj='$dj'";
 $result=mysql_query($sql);
 $rows=mysql_fetch_array($result);
 ?>

<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td colspan="3"><strong>Update The information for the Now PlayingProgram.</strong>
</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Email</strong></td>
<td align="center"><strong>Email2</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">
<input name="name" type="text" id="name" value="<?php echo $rows['name']; ?>">
</td>
<td align="center">
<input name="email" type="text" id="email" value="<?php echo $rows['email']; ?>" size="15">
</td>
<td>
<input name="email2" type="text" id="email2" value="<?php echo $rows['email2']; ?>" size="15">
</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center"><strong>Twitter</strong></td>
<td align="center"><strong>Twitter2</strong></td>
<td align="center"><strong>Avatar</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">
<input name="twitter" type="text" id="twitter" value="<?php echo $rows['twitter']; ?>">
</td>
<td align="center">
<input name="twitter2" type="text" id="twitter2" value="<?php echo $rows['twitter2']; ?>" size="15">
</td>
<td>
<input name="avatar" type="text" id="avatar" value="<?php echo $rows['avatar']; ?>" size="15">
</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center"><strong>Facebook</strong></td>
<td align="center"><strong>Facebook2</strong></td>
<td align="center"><strong>Type</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">
<input name="facebook" type="text" id="facebook" value="<?php echo $rows['facebook']; ?>">
</td>
<td align="center">
<input name="facebook2" type="text" id="facebook2" value="<?php echo $rows['facebook2']; ?>" size="15">
</td>
<td>
<input name="type" type="text" id="type" value="<?php echo $rows['type']; ?>" size="15">
</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center"><strong>Alias1</strong></td>
<td align="center"><strong>Alias2</strong></td>
<td align="center"><strong>Alias3</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center">
<input name="alias1" type="text" id="alias1" value="<?php echo $rows['alias1']; ?>">
</td>
<td align="center">
<input name="alias2" type="text" id="alias2" value="<?php echo $rows['alias2']; ?>" size="15">
</td>
<td>
<input name="alias3" type="text" id="alias3" value="<?php echo $rows['alias3']; ?>" size="15">
</td>
</tr>

<tr>
<td align="center">&nbsp;</td>
 <td colspan="3" align="center"><strong>Request Line</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3" align="center">
 <input name="address" type="text" id="address" value="<?php echo $rows['address']; ?>" size="65">
 </td>
 </tr>
 <tr>
 <td>&nbsp;</td>
 <td>
 <input name="dj" type="hidden" id="dj" value="<?php echo $rows['dj']; ?>">
 </td>
 <td align="center">
 <input type="submit" name="Submit" value="Submit">
 </td>
 <td>&nbsp;</td>
 </tr>
 </table>
 </td>
 </form>
 </tr>
 </table>
  <?php
 // close connection 
 mysql_close();
 ?>

Now what I want to be able to do is to edit the information in the database that is currently displayed in the form. (the form is displaying the correct info from mysql)
If i wanted to change lets say the email2 i would just do so in the field and then click submit. Well my issue is that when I do that, all i get is ERROR.

So lets take a look at my update_ac.php
code is below:

<?php
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name=""; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// update data in mysql database 
$sql="UPDATE currentdj SET  name='$name',
                        email='$email',
                        email2='$email2',                           
                        twitter='$twitter',
                        twitter2='$twitter2',
                        avatar='$avatar',                           
                        facebook='$facebook',
                        facebook2='$facebook2',
                        type='$type',
                        alias1='$alias1',
                        alias2='$alias2',
                        alias3='$alias3',
                        address='$address'                          
                        WHERE dj='$dj'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}

else {
echo "ERROR";
}

?>

I would like to know if I am just having a syntax or even a spelling issue here!
Any help would be appreciated.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:40:23+00:00Added an answer on June 12, 2026 at 1:40 pm

    In your update_ac.php file , you haven’t used $_POST[] variable to retrieve values from your form. As a result no values are being inserted in the database and hence the error.

    Put this code before the update query statement where you have $sql=”UPDATE…..

     $email=$_POST['email'];
     $email2=$_POST['email2'];                          
     $twitter=$_POST['twitter'];
    

    and so on…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do something really simple here. All I want to do
I'm trying to do something really simple here but it's kicking my butt haha.
I am probably overlooking something really simple here but I am trying to redirect
actually I thought I was trying something really simple. ControllerClassNameHandlerMapping sounded great to produce
I'm trying to do something really simple, but starting to realize that dates in
I am sure this is something really simple, but I am going bonkers trying
I'm trying to do something that would be really simple in any other language
Something really odd going on here, and I have gone round in circles trying
I am trying to do something really simple, but somehow not getting the direction.
I am trying to so something really, really simple, but Entity Framework seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.