Jump to content

POST problem


fouzan

Recommended Posts

I get this error-->Notice: Undefined index: name in C:\wamp\www\sedit.php on line 13

 

 

<?php
session_start();

$db_handle = mysql_connect("localhost", "root", "");
$db_found = mysql_select_db("fouzan_db", $db_handle);

if ($db_found) { echo "connected.<br/>";
if (isset($_POST['xyz']))

  {
   $me = $_POST['text'];
$sql="UPDATE `slogin` SET `data`='$me' WHERE username= '$_SESSION[name]'";
$result = mysql_query($sql);  //to inform this is a query

  echo "Thank you for using our mail form";
  }


else {


echo "<form method='post' action='sedit.php' />



  Message:<br />
  <textarea name='text' rows='15' cols='80'>
  </textarea><br />
  <input type='submit'value='submit' name='xyz'/>
  </form>";
} }
else {
print "Database NOT Found ";
mysql_close($db_handle);
} 
?>
<html>
<body>
<head>
  
</head>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/253629-post-problem/
Share on other sites

It doesn't need single quotes within a double quoted string. In fact, quoting the array index within a double quoted string without using complex notation will throw this: Parsing Error: /Applications/MAMP/htdocs/test.php line 10 - syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 

$query = "SELECT field FROM table WHERE field = '$_SESSION[name]'"; // This is fine
$query = "SELECT field FROM table WHERE field = '{$_SESSION['name']}'"; // This is fine
$query = "SELECT field FROM table WHERE field = '$_SESSION['name']'";  // Throws parse error.

Link to comment
https://forums.phpfreaks.com/topic/253629-post-problem/#findComment-1300289
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.