Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.