I’m trying to create a custom module and I’m trying to get MY SQL access.
But i keep getting
mysql_query() [function.mysql-query]: Access denied for user
‘scripts’@’localhost’ (using password: NO) in
/home/scripts/public_html/crm/modules/PcPal/book-engineer.php on line
14
How do I access the data on the database when making a sugar module?
<?php if(!defined('sugarEntry') || !sugarEntry) die ('Not A valid Entry point'); ?>
<h2>Book an Engineer</h2>
<form method="POST" >
Search Last Name : <input type="text" name="frm_last_name_search" value="<?php echo $_POST['frm_last_name_search']; ?>" />
<input type="submit" value="Search"/>
</form>
<?php
$sql = 'SELECT first_name, last_name, primary_address_street FROM contacts WHERE last_name = \''.$_POST['frm_last_name_search'].'\'';
$results = mysql_query($sql);
while($this_result = mysql_fetch_array($result))
{
print_r($this_result);
}
?>
You should look into using the bean methods for very common queries like this, as it’s easier and more portable.
http://developers.sugarcrm.com/wordpress/2012/03/23/howto-using-the-bean-instead-of-sql-all-the-time/