Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys !
I am getting my query working but i dont know a Notice message on top on query result !

Notice: Use of undefined constant admin - assumed 'admin' in C:\xampp\htdocs\test\mysql.php on line 13
A total of 1 records were found.


I am using two diffent pages for my web are:

connection.inc.php
PHP
<?php
function dbConnect($type) {
if ($type == 'query') {
$user = 'globalluser';
$pwd = 'member';
}
elseif ($type == 'admin') {
$user = 'globalladmin';
$pwd = 'essendon';
}
else {
exit('Unrecognized connection type');
}
// Connection code goes here

    $mysql_host = 'localhost';
    $mysql_user = 'globalladmin';
    $mysql_pass = 'essendon';

    $mysql_db = 'globall';

if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass) || !mysql_select_db($mysql_db)){
die(mysql_error());
}
}

?>




mysql.php
XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>data </title>
</head>
<body>
<?php

include 'connection.inc.php';

// connect to MySQL
$conn = dbConnect(admin);

// prepare the SQL query
$sql = 'SELECT * FROM customer';

// submit the query and capture the result
$result = mysql_query($sql) or die(mysql_error());

// find out how many records were retrieved
$numRows = mysql_num_rows($result);
?>

<p>A total of <?php echo $numRows; ?> records were found.</p>



</body>
</html>
Posted

The message says that PHP is being good to you. In
PHP
// connect to MySQL
$conn = dbConnect(admin);

you left out the quotes surrounding admin. PHP couldn't find a symbol of that name, so it guessed you wanted quotes around it. Then it went on and did your query successfully.

Cheers,
Peter
 
Share this answer
 
v2
thanks its working. anu suggestion i am getting my query result in table, Can i design interactive table instead of very simple outlook ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900