EllisLab text mark
Advanced Search
     
Use of undefined constant data - assumed ‘data’ in C:\wamp\www\cms\yourpage.php on line 33
Posted: 19 February 2009 11:33 AM
Joined: 2009-02-19
6 posts
<?php function nukeMagicQuotes() {
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value{
$value 
is_array($value) ? array_map('stripslashes_deep'$value) : stripslashes($value);
return 
$value;
}
$_POST 
array_map('stripslashes_deep'$_POST);
$_GET array_map('stripslashes_deep'$_GET);
$_COOKIE array_map('stripslashes_deep'$_COOKIE);
}
}
?>
<?php nukeMagicQuotes
(); ?>
<?php 
// Connect to the database
  
$cnx mysql_connect("localhost""root""");
         if (!
$cnx
         
die("Unable to connect to database!");
         
}
          
// Select your database
  
mysql_select_db("fckdata"$cnx);
  
// Get data from the database
  
$query mysql_query("SELECT data FROM fck_data WHERE id = 1");
  
$data mysql_fetch_array($query);
  
?>

<!-- This is where the content from your database is displayed
we are telling the database to display the content from the field in
the database called data 
-->
<
div>
  
<?php echo $data[data]?>
</div
 
Posted: 19 February 2009 11:37 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-04-25
4956 posts

You haven’t used quotes, so PHP checks to see if any constants have been defined by that name. As there isn’t one, it assumes it should be a string, and gives you a warning to let you know.

<?php echo $data['data']?> 
 Signature 

http://www.phptherightway.com

Remember the 8 Ps: Perfect Planning and Prior Preparation Prevents Piss-Poor Performance.

 
Posted: 19 February 2009 03:48 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-02-19
6 posts

thank you very much, it works.