Don't let on about the password...
We seem to have stalemate. I'm getting this it the bottom of the screen:
select * from survey where name= and comments=''
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/nobloque/public_html/survey.php on line 131
after splicing in your code.
The complete code (with password cleverly removed) is here:
......................
<body>
<?php
$host = "localhost";
$user = "nobloque";
$pass = "???????";
$dbname = "nobloque_survey";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$name =$_POST['name'];
$region =$_POST['region'];
$type =$_POST['type'];
$comments =$_POST['comments'];
$email =$_POST['email'];
$url =$_POST['url'];
?>
<!-- here's the html form -->
<table class=questiontable cellspacing=2>
<form method='post' action='survey.php'>
<tr>
<td class=fieldlabel>name</td>
<td class=field><input class=input type="text" name="name" size="35"></td></tr>
<tr>
<td class=fieldlabel>region</td>
<td class=field><input class=input type="text" name="region" size="35"></td></tr>
<tr>
<td class=fieldlabel>what type of area do you live in?</td>
<td class=field>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td class=radiobuttons>big town</td>
<td class=radiobuttons><input type="radio" name="type" value="bigtown" checked="unchecked"></td></tr>
<tr>
<td class=radiobuttons>small town</td>
<td class=radiobuttons><input type="radio" name="type" value="smalltown" checked="unchecked"></td></tr>
<tr>
<td class=radiobuttons>country</td>
<td class=radiobuttons><input type="radio" name="type" value="country" checked="unchecked"></td></tr>
</table>
</td></tr>
<tr>
<td class=fieldlabel>your experiences</td>
<td class=field>
<textarea class=input wrap='virtual' style='width: 245px; height:100px' name=comments>
</textarea>
<tr>
<td class=fieldlabel>e-mail address</td>
<td class=field><input class=input type="text" name="email" size="35"></td></tr>
<tr>
<td class=fieldlabel>url of web-site, blog &c.</td>
<td class=field><input class=input type="text" name="url" size="35"></td></tr>
<tr>
<td colspan=2 class=fieldlabel>
<table style="float:right" border=0 cellpadding=0 cellspacing=0>
<td style='padding-right:10px'><input type="submit" value="Enviar"></td>
<td><input type="reset" value="Cancelar"></td>
</table>
</td></tr>
</form>
</table>
<!-- END OF html form -->
<?php
if ($comments != "")
{
$dbh=mysql_connect ($host, $user, $pass, $dbname) or die ('Error: Connection error: cannot connect to the database' . mysql_error());
mysql_select_db ($dbname) or die( "Error: Selection error, Unable to select database $dbname" . mysql_error());
$query = "INSERT INTO 'survey'
('name' , 'region' , 'type', 'comments' , 'email' , 'url')
VALUES
('$name' , '$region' , '$type', '$comments' , '$email' , '$url')
";
mysql_query($query);
}
if(isset($_POST)){
$sql = "select * from survey where name=" . $_POST['comments'] . " and comments='" . $_POST['comments'] . "'";
echo $sql;
$query = mysql_query($sql);
}
?>
<table class=questiontable cellspacing=2>
<?php
// Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (line below)
while ($row = mysql_fetch_array($query)) {
echo "<tr>
<td class='feedback'>", $row['region'], "</td>
<td class='feedback'>", $row['comments'], "</td></tr>";
}
?>
</table>
</body>
</html>
.................................
So there are still two glitches:
1) We're getting an echo of
select * from survey where name= and comments=''
on the screen even using your fix thus:
if(isset($_POST)){
$sql = "select * from survey where name=" . $_POST['comments'] . " and comments='" . $_POST['comments'] . "'";
echo $sql;
$query = mysql_query($sql);
}
2) 'Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource' relates to this line:
while ($row = mysql_fetch_array($query)) {
echo "<tr>
<td class='feedback'>", $row['region'], "</td>
<td class='feedback'>", $row['comments'], "</td></tr>";
}
Any clues?