List:General Discussion« Previous MessageNext Message »
From:Don Read Date:May 10 1999 8:05am
Subject:RE: PHP and mysql_result Need to reference the record I just ins
View as plain text  
On 08-May-99 Van wrote:
> Okay, I'm beatin' myself up, and 4900 archived mysql messages later,
> still dying on the vine.
> Doing a feedback form in PHP.  Works fine.  Inserts the record.  Code
> follows:
> $link = mysql_connect($dbhost, $dbuser, $dbpasswd);
> mysql_select_db($db,$link);
> 
> $Result=mysql_query("INSERT INTO $dbtable VALUES ('', '$UserAgent',
> '$Referer',
>       '$ScriptFilename', '$HitTime', '$RemoteHost', '$RemoteAddr',
>       '$EmployeeRating', '$SafeComments','$FullName','$eMail')", $link);
> 
> $CommentId=$Result[1];
> echo "<center>CommentId=$CommentId; Result=$Result";
> mysql_close($Result);
> 

That works ?? 
as a C pgmr -> php newbie i get real shy about quoting in php; i always sprintf
the query, but if you say so ...

anyhow try:
  if (mysql_query(INSERT INTO .... )) {

    $CommentId=mysql_insert_id($link);
    printf("<center>CommentId=%d Result=%d\n",$CommentId, $Result);
  } else 
     echo "really bad vibes, dude ..";


http://www.php.net/manual/function.mysql-query.php3
http://www.php.net/manual/function.mysql-insert-id.php3

Regards,
---
Don Read                        sysop@stripped
EDP Manager                         dread@stripped
Calcasieu Lumber                       Austin Texas
-  A baby is God's opinion that the world should go on.
Thread
How enable symlink-aware behavior?Scott Weikart3 Apr
  • How enable symlink-aware behavior?Michael Widenius3 Apr
  • PHP and mysql_result Need to reference the record I just insertedVan9 May
    • RE: PHP and mysql_result Need to reference the record I just insDon Read10 May
      • Re: PHP and mysql_result Need to reference the record I just insVan10 May