I have a code for fetching and where I use it in Drupal and How?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Praveen Dhyani's picture

I have made a Code is this right
Where and In Which file I use this code

<?php
$con
= mysql_connect("localhost", "user", "user123!");
if (!
$con)
  {
  die(
'Could not connect: ' . mysql_error());
  }

$db_selected = mysql_select_db("drupalweb", $con);

if (!
$db_selected)
  {
  die (
"Can\'t use test_db : " . mysql_error());
  }
   
$query = db_select('test1_drupal');
   
$query->fields('test1_drupal', array('rollno', 'name','result'));
   
$query->condition('regno', $regno);
   
$result1 = $query->execute()->fetch();
  
   
drupal_set_message($result1->rollno);
   
drupal_set_message($result1->name);
   
drupal_set_message($result1->result);
   
mysql_close($con);
?>

Comments

You can't use this php code

rajeevk's picture

You can't use this php code in Drupal.

Drupal communicate with DB in it's own manner.

If you can define what you want to achieve for your application then may be I can help you.

Feel free to write - Rajeevkr.hcas@gmail.com

Thanks.