Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 11th, 2005, 09:21 AM
Authorized User
 
Join Date: Jan 2005
Location: ipaja, lagos, Nigeria.
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to p2ptolu Send a message via Yahoo to p2ptolu
Default problems displaying data

 I am new in php help out please: my setup is below :

win XP pro
Apache 2.0.54
PHP 4.3.4
Mysql 3.23.49
PhpMyAdmin 2.6.2

i used the code in my php after creating my databse in PhpMyAdmin 2.6.2 but i got this error message:
(Notice: Undefined variable: metode in C:\DocRoot\updc\results.php on line 34

Notice: Undefined variable: search in C:\DocRoot\updc\results.php on line 34

Notice: Undefined variable: variable1 in C:\DocRoot\updc\results.php on line 51
No Record Found, to search again please close this window
)

Please help me out,



CODES IN PHP

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<center>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<td width="60"><b>id</b></td>
<td width="100"><b>name</b></td>
<td width="70"><b>telephone</b></td>
<td width="150"><b>birthday</b></td>
</tr>
<tr>
<td>

<?

$hostname = "localhost"; // The Thinkhost DB server.
$username = "root"; // The username you created for this database.
$password = "unitysch"; // The password you created for the username.
$usertable = "details"; // The name of the table you made.
$dbName = "lopez"; // This is the name of the database you made.

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
//error message (not found message)begins
$XX = "No Record Found, to search again please close this window";
//query details table begins
$query = mysql_query("SELECT * FROM details WHERE $metode LIKE '%$search%' LIMIT 0, 50");
while ($row = @mysql_fetch_array($query))
{
$variable1=$row["id"];
$variable2=$row["name"];
$variable3=$row["telephone"];
$variable4=$row["birthday"];
//table layout for results

print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("</tr>");
}
//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
?>
</table>
</center>
</body>
</html>

Reply With Quote
  #2 (permalink)  
Old May 11th, 2005, 11:31 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1st look:

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
//error message (not found message)begins

Remove
?>
<?

I'm also not so square about my coding, so I would have wrote this:
$query = mysql_query("SELECT * FROM details WHERE $metode LIKE '%$search%' LIMIT 0, 50");
while ($row = @mysql_fetch_array($query))
{
$variable1=$row["id"];
$variable2=$row["name"];
$variable3=$row["telephone"];
$variable4=$row["birthday"];
//table layout for results

print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("</tr>");
}

like this:

$query = mysql_query("SELECT * FROM details WHERE $metode LIKE '%$search%' LIMIT 0, 50");
while ($row = @mysql_fetch_array($query))
{
extract($row);
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $name; ?></td>
<td><?php echo $telephone; ?></td>
<td><?php echo $birthday; ?></td></tr></table>
<?php } ?>
Reply With Quote
  #3 (permalink)  
Old May 12th, 2005, 01:12 AM
Authorized User
 
Join Date: Feb 2005
Location: tehran, , Iran.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
 you should defined your variable $metode &search in
your program
OR
if you send these variable from another page to this page
you should submit your variable and use this code in your program:

$metode=&_POST['$metode'];
$search=$_POST['$searrch'];

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying My Data jamil umar ASP.NET 2.0 Basics 0 June 5th, 2006 09:48 AM
Problems Displaying an image retrieved from SQL Se jazzcatone ASP.NET 1.x and 2.0 Application Design 2 September 3rd, 2005 09:53 AM
Problems with displaying sub-cats... enchen PHP Databases 0 April 20th, 2005 05:23 AM
Problems displaying images via a variable nancy Classic ASP Basics 2 June 2nd, 2004 02:17 PM
Problems displaying web pages using IIS kathryne Classic ASP Professional 1 November 14th, 2003 12:48 PM



All times are GMT -4. The time now is 01:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.