Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199903

[PHP3] 1 is not a MySQL result index ? From: Erik (stainsby <email protected>)
Date: 03/31/99

Hi. Help?

I'm missing something ... The following connects to a mysql db, inserts
strings set in a form page and should then echo back the current state of
the page. Unfortunately it complains that "1 is not a MySQL result index"
after I attempt to read the table. The writes to the table work fine and at
this point there are a dozen or more lines there to be read. Could someone
point out the error of my ignorant ways? Please?

Erik
stainsby <email protected>

=================

<?
  echo $acctCode . "<BR>";
  echo $text . "<P>";

$conn = MYSQL_CONNECT("localhost","nobody","") OR DIE("Unable to connect to
database");
if (! $conn) {
    echo "A server connection could not be established.\n";
    exit;
}

$query = "INSERT INTO echo VALUES('$acctCode','$text')";
$result = mysql_db_query("lets",$query,$conn);
echo "INSERT affected: " . $result . "<BR>";

$second_query = "SELECT * FROM echo";
$second_result = mysql_db_query("lets",$query,$conn);
echo "SELECT result: " . $second_result . "<P>";

$num = mysql_num_rows($second_result);
echo "NumRows: " . $second_result . "<P>";

$i = 0;
while ($i < $num) {
  echo "<TR><TD>";
  echo mysql_result($second_result, $i, "acctCode");
  echo "</TD><TD>";
  echo mysql_result($second_result, $i, "text");
  echo "</TD></TR>";
  $i++;
}
mysql_FreeResult($result);
mysql_Close($conn);

?>

--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list:  php3-digest-subscribe <email protected>
For help: php3-help <email protected>  Archive:  http://www.php.net/mailsearch.php3
List administrator:  zeev-list-admin <email protected>