0

Sir, I am using these codes

if(isset($_POST['update']))
    {
    // Get values from form 
    $name=$_POST['name'];
    $moba=$_POST['moba'];
    $mobb=$_POST['mobb'];
    $ptcl=$_POST['ptcl'];
    $fax =$_POST['fax'];
    $email=$_POST['email'];
    $web =$_POST['web'];
    $add =$_POST['add'];
    $city =$_POST['city'];
    $country =$_POST['country'];
    $job =$_POST['job'];
    $office =$_POST['office'];
    $place =$_POST['place'];
    $phone =$_POST['phone'];
    $others =$_POST['others'];


    if (empty($moba)){
            echo "<script>alert('No username is selected')</script>";
        }else{

$query = "UPDATE contacts SET  name=$name mobb=$mobb ptcl=$ptcl fax=$fax email=$email web=$web address=$add city=$city country=$country job=$job office=$office place=$place phone=$phone others=$others where moba='".$_POST['$moba']."'";
            $result = mysqli_query($con, $query)or die (mysqli_error());

        //check update
            if(!$result)
            {
            echo ("<script>alert('Sorry! Something went wrong.')</script>");
            }else{
            echo ("<script>alert('Record updated successfully')</script>"); 
            }
        }

but it says:

Notice: Undefined index: $moba in C:\wamp\www\Phonebook\contacts.php on line 110

and line 110 is

$query = "UPDATE contacts SET  name=$name mobb=$mobb ptcl=$ptcl fax=$fax email=$email web=$web address=$add city=$city country=$country job=$job office=$office place=$place phone=$phone others=$others where moba='".$_POST['$moba']."'";

My database is as follows:

http://i44.tinypic.com/jpzwok.jpg

What I am doing wrong?
Please help me

Edited by pritaeas: Fixed post. We use markdown, not bbcode.

2
Contributors
5
Replies
15
Views
3 Years
Discussion Span
Last Post by pritaeas
0

You query is missing comma's and single quotes. It will never run.

You should change

$_POST['$moba']

to either

$_POST['moba']

or

$moba
0

Thanks Sir, one problem solved, now i am facing this this problem

Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\Phonebook\contacts.php on line 111

line 111 is

$result = mysqli_query($con, $query)or die (mysqli_error());
0

Sir I have modified as

$result = mysqli_query($con, $query)or die (mysqli_error($con));

now it says:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mobb= ptcl= fax= email= web= address= city= country= job= office= place= phone= ' at line 1

what does it means?

0

You query is missing comma's and single quotes. It will never run.

Check the MySQL manual to see how an UPDATE query should be written.

Edited by pritaeas

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.