Jump to content

[SOLVED] PHP producing garbage output?


dub_stylee

Recommended Posts

Hello all, I am new to the site.  I have tried searching the forums before creating this posting, to no avail.  Sorry if this has been asked/answered before.  I am trying to use PHP to generate a selection list based on the results of a MySQL query.  I have had similar problems trying to use published examples, so I am thinking that it may be a configuration problem on my web server?  Anyway, here is the garbage output that I am receiving when trying to view my page (some info will be omitted for privacy):

 

"; echo ""; echo ""; $host = "******"; $port = "****"; $user = "guest"; $pass = "guest"; $dbname = "stores7"; $conn = mysql_connect("$server", "$user", "$pass") or die("MySQL Connection Error"); $db = mysql_select_db($dbname) or die("Missing Database"); $query = "SELECT manu_name FROM manufact"; echo "$query"; echo $query; $result = mysql_query($query) or die("Invalid Query"); echo "$result"; echo $result; /* create the selection list */ echo "

\n"; echo "

\n"; echo ""; echo ""; ?>

 

And of course, the .html file:

 

<?php

/* Filename: index.html

* Description: home page

*/

 

echo "<html>";

echo "<head><title>myTunes Database</title></head>";

echo "<body>";

 

$host = "*****";

$port = "****";

$user = "guest";

$pass = "guest";

$dbname = "stores7";

 

$conn = mysql_connect("$server", "$user", "$pass")

or die("MySQL Connection Error");

 

$db = mysql_select_db($dbname)

or die("Missing Database");

 

$query = "SELECT manu_name FROM manufact";

 

echo "$query";

echo $query;

 

$result = mysql_query($query)

or die("Invalid Query");

 

echo "$result";

echo $result;

 

/* create the selection list */

echo "<form action = 'processform.php' method = 'POST'>

      <select name = '$manu_name'>\n";

 

while ($row = mysql_fetch_array($result))

{

  extract($row);

  echo "<option value='$manu_name'>$manu_name</option>\n";

}

 

echo "</select>\n";

echo "<input type = 'submit' value = 'Select Manufacturer'>

      </form>\n";

 

echo "</body>";

echo "</html>";

?>

 

Thanks very much in advance!

 

Brian ???

Link to comment
https://forums.phpfreaks.com/topic/135858-solved-php-producing-garbage-output/
Share on other sites

Humm.. is this a php file (end with .php) also

echo "<form action = 'processform.php' method = 'POST'>
      <select name = '$manu_name'>\n";

should probably be

echo "<form action = 'processform.php' method = 'POST'>
      <select name = 'manu_name'>\n";

Your php doesn't seem to be working. Try the simple file:

 

<?php echo "Hello World!": ?>

 

and then view-source. If you see anything other than "Hello World!" your php definitely isn't working properly. If you view-source on this page you've posted here does it look exactly like your script?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.