-3

everyone here .. now i got an problem , so please help me , because I am new with php code. I want to get value from url but the result is Undefined index

this is url : http://4you4me.com/admin/index_edit_form.php?edit=76

php code :

 if(isset($_REQUEST['edit']) === TRUE && ! empty($_REQUEST['edit']))
        $con_id_update = mysql_real_escape_string((int)$_REQUEST['edit']);
print_r($con_id_update);

The result is undefined Variable:con_id_update

what is wrong with this script? thank for your answer.

phireak
  • 45
  • 2
  • 8

3 Answers3

0

It looks like you're missing the curly braces:

if(isset($_REQUEST['edit']) === TRUE && ! empty($_REQUEST['edit'])) {
    $con_id_update = mysql_real_escape_string((int)$_REQUEST['edit']);
    print_r($con_id_update );
}

If you don't wrap the curly bracers around the entire statement, only the line after the if statement will be executed.

Hau Nguyen
  • 166
  • 4
0

try this :

$con_id_undate ='';// to initialize 

 if(isset($_GET['edit']) && !empty($_GET['edit']))
            $con_id_update = (int)$_GET['edit'];

    print_r($con_id_undate);

You shouldn't use $_REQUEST

Also you should use msqli instead of mysql. Since you cast the value to an int you don't need to use mysql_real_escape_string.

mysql_real_escape_string (mysqli_real_escape_string) tends to work only when their is already an open connection

Community
  • 1
  • 1
Jeffrey Nicholson Carré
  • 2,950
  • 1
  • 26
  • 44
0

You should get value from url using $_GET instead of $_REQUEST if you know exactly what you want, good luck!

Killer Whale
  • 87
  • 2
  • 12