Jump to content

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

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.