Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP/MySQL testing server issue
Old 06-18-2009, 02:35 PM PHP/MySQL testing server issue
Experienced Talker

Posts: 48
Name: Craig
Trades: 0
I'm relatively new to the database world, so please excuse me for a simple question...

I have a MySQL database set up on my web server, and a php script to search the database. It outputs everything perfectly. When I try to run it locally, my results page only shows the variables that were defined, not the info from the database. It looks like this...

Name: $lname, $fname $mi

...instead of...

Name: Public, John Q

like it does when I run it online.

I have tried it running WAMPServer and xampp, but I get the same results either way. Can someone please tell me what I'm missing?

Search Page:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin List</title>

<link href="admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="header"><h1>Search the Admin List</h1></div>
<div id="contents">
<div id="search">
<form method="post" action="search.php">
<label for="search">Name:</label><input type="text" id="status" name="search" size=25 maxlength=25>
<input type="Submit" name="Submit" value="Search">
</form>
</div>
</div>
</body>
</html>
Results Page:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="output.css" rel="stylesheet" type="text/css" />
</head>
<body>
<input type=button value="Back" onClick="history.go(-1)">
<div id="output">
<?
mysql_connect
("localhost","*username*","*pw*"); 

mysql_select_db("*db*"); 

$search=$_POST["search"];

$result mysql_query("SELECT * FROM name WHERE lname LIKE '%$search%'");


while(
$r=mysql_fetch_array($result))
{    

   
$lname=$r["lname"];
   
$fname=$r["fname"];
   
$mi=$r["mi"];
   
$admin=$r["admin"];
   
$floor=$r["floor"];
   
   echo 
"<b>Name:</b> $lname$fname $mi <br><b>Admin/Dept:</b> $admin <br><b>Floor/Building:</b> $floor <br><hr>";
}
?>
</div>
</body>
</html>
werm82 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-18-2009, 05:19 PM Re: PHP/MySQL testing server issue
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I'd say that you have an error in th apache/php configuration.
Do you just see
Code:
$lname, $fname $mi
or do you see all the PHP code ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-18-2009, 07:41 PM Re: PHP/MySQL testing server issue
Experienced Talker

Posts: 48
Name: Craig
Trades: 0
No php code, just $lname, etc.

Know any good places I could read up on setting up a local server?
werm82 is offline
Reply With Quote
View Public Profile
 
Old 06-19-2009, 05:06 AM Re: PHP/MySQL testing server issue
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
try using full php tags

<?php


?>
__________________

Please login or register to view this content. Registration is FREE
davidj is offline
Reply With Quote
View Public Profile
 
Old 06-19-2009, 05:58 AM Re: PHP/MySQL testing server issue
Experienced Talker

Posts: 48
Name: Craig
Trades: 0
Wow, three little letters... Worked great! Thanks so much!
werm82 is offline
Reply With Quote
View Public Profile
 
Old 06-19-2009, 11:02 AM Re: PHP/MySQL testing server issue
Experienced Talker

Posts: 48
Name: Craig
Trades: 0
*Nevermind, I figured it out. I was running the html file in the browser instead of http://localhost. Sorry!*

So, I got to work where I will be using the database, and I'm still having the same issue. Everything is exactly the same as it is on my home computer, but it still gives

Code:
Name: $lname, $fname
Any idea what I should look into?

Last edited by werm82; 06-19-2009 at 11:07 AM..
werm82 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP/MySQL testing server issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48951 seconds with 12 queries