Z
zanadoo88
Guest
So, I am trying to write some test code to get some info into a MySQL database and then display it. Seems simple, right? But I can't get it to display anything! What am I doing wrong?
<HTML><BODY><?
$username="Chewy2";
$password="Password7";
$database="Chewy1";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO Test1 ('html' , 'votes' , 'rate')VALUES ('yootube123','5','10')";
$query="SELECT * FROM contacts";
mysql_close();
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$rate=mysql_result($result,$i,"rate");
echo "$rate";
$i++;
}
?></BODY></HTML>
OK, I made the changes and it still doesn't work
<HTML><BODY><?
$username="Chewy1";
$password="Password8";
$database="Chewy";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO Test1 ('html' , 'votes' , 'rate')VALUES ('yootube123','5','10')";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$rate=mysql_result($result,$i,"rate");
echo "$rate";
$i++;
}
mysql_close();
?></BODY></HTML>
<HTML><BODY><?
$username="Chewy2";
$password="Password7";
$database="Chewy1";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO Test1 ('html' , 'votes' , 'rate')VALUES ('yootube123','5','10')";
$query="SELECT * FROM contacts";
mysql_close();
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$rate=mysql_result($result,$i,"rate");
echo "$rate";
$i++;
}
?></BODY></HTML>
OK, I made the changes and it still doesn't work
<HTML><BODY><?
$username="Chewy1";
$password="Password8";
$database="Chewy";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO Test1 ('html' , 'votes' , 'rate')VALUES ('yootube123','5','10')";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$rate=mysql_result($result,$i,"rate");
echo "$rate";
$i++;
}
mysql_close();
?></BODY></HTML>