While this is more of a PHP suggestion than RH or linux specific, just
noticed you might change your code in the future to be more efficient...
$db = mysql_connect ("localhost","user","pass") or die ("Could not connect
to mySQL server.");
mysql_select_db ("mymaindb",$db) or die ("Could not select Database");
$result = mysql_query("SELECT * FROM theTable",$db);
if (!$result) $errorString .= "<FONT CLASS='error'>Error ::
".mysql_errno($db)." :: ".mysql_error($db)."<BR>".$sql."<BR></FONT>\n";
if (mysql_num_rows($result) > 0 )$row = mysql_fetch_assoc($result);
Then all your fields from "theTable" will be in $row['name'], $row['age'],
etc... (if you had results, otherwise you'll get errors)
mysql_result() is old and IMHO depricated.
http://us2.php.net/manual/en/function.mysql-result.php
Use this instead. You'll keep more of your hair, and look cool to all the
other kids.
http://us2.php.net/manual/en/function.mysql-fetch-assoc.php
Another handy dandy trick is this, bequethed upon me by Rasmus himself...
while(list($myVariableName,$sqlFieldName)=each($row)) { $$myVariableName =
$sqlFieldName; }
Now all your fieldnames are in a variable of the same name ;-)
Like $name, $age, etc...
Daevid Vincent
http://daevid.com
> -----Original Message-----
> test code:
>
> #!/usr/local/bin/php
> <?
> $db = mysql_connect(localhost, "user", "pass");
> mysql_select_db("mymaindb",$db);
> $result = mysql_query("SELECT * FROM theTable",$db);
> printf("l1: %s\n", mysql_result($result,0,"some_column"));
> ?>
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list