<HTML ><HEAD ><TITLE >sesam_diagnostic</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="SESAM database functions" HREF="ref.sesam.html"><LINK REL="PREVIOUS" TITLE="sesam_connect" HREF="function.sesam-connect.html"><LINK REL="NEXT" TITLE="sesam_disconnect" HREF="function.sesam-disconnect.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual de PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sesam-connect.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.sesam-disconnect.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.sesam-diagnostic" ></A >sesam_diagnostic</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN69065" ></A ><P > (PHP 3 CVS only)</P >sesam_diagnostic -- Return status information for last SESAM call </DIV ><DIV CLASS="refsect1" ><A NAME="AEN69068" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >sesam_diagnostic</B > ( void)<BR ></BR ><P > Returns an associative array of status and return codes for the last SQL query/statement/command. Elements of the array are: <DIV CLASS="table" ><A NAME="AEN69075" ></A ><P ><B >Tabla 1. Status information returned by <B CLASS="function" >sesam_diagnostic()</B > </B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Element</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Contents</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$array["sqlstate"]</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > 5 digit SQL return code (see the SESAM manual for the description of the possible values of SQLSTATE) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$array["rowcount"]</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > number of affected rows in last update/insert/delete (set after "immediate" statements only) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$array["errmsg"]</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > "human readable" error message string (set after errors only) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$array["errcol"]</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > error column number of previous error (0-based; or -1 if undefined. Set after errors only) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$array["errlin"]</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > error line number of previous error (0-based; or -1 if undefined. Set after errors only) </TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > In the following example, a syntax error (E SEW42AE ILLEGAL CHARACTER) is displayed by including the offending SQL statement and pointing to the error location: <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN69100" ></A ><P ><B >Ejemplo 1. Displaying SESAM error messages with error position</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // Function which prints a formatted error message, // displaying a pointer to the syntax error in the // SQL statement function PrintReturncode ($exec_str) { $err = Sesam_Diagnostic(); $colspan=4; // 4 cols for: sqlstate, errlin, errcol, rowcount if ($err["errlin"] == -1) --$colspan; if ($err["errcol"] == -1) --$colspan; if ($err["rowcount"] == 0) --$colspan; echo "<TABLE BORDER>\n"; echo "<TR><TH COLSPAN=".$colspan."><FONT COLOR=red>ERROR:</FONT> ". htmlspecialchars($err["errmsg"])."</TH></TR>\n"; if ($err["errcol"] >= 0) { echo "<TR><TD COLSPAN=".$colspan."><PRE>\n"; $errstmt = $exec_str."\n"; for ($lin=0; $errstmt != ""; ++$lin) { if ($lin != $err["errlin"]) { // $lin is less or greater than errlin if (!($i = strchr ($errstmt, "\n"))) $i = ""; $line = substr ($errstmt, 0, strlen($errstmt)-strlen($i)+1); $errstmt = substr($i, 1); if ($line != "\n") print htmlspecialchars ($line); } else { if (! ($i = strchr ($errstmt, "\n"))) $i = ""; $line = substr ($errstmt, 0, strlen ($errstmt)-strlen($i)+1); $errstmt = substr($i, 1); for ($col=0; $col < $err["errcol"]; ++$col) echo (substr($line, $col, 1) == "\t") ? "\t" : "."; echo "<FONT COLOR=RED><BLINK>\\</BLINK></FONT>\n"; print "<FONT COLOR=\"#880000\">".htmlspecialchars($line)."</FONT>"; for ($col=0; $col < $err["errcol"]; ++$col) echo (substr ($line, $col, 1) == "\t") ? "\t" : "."; echo "<FONT COLOR=RED><BLINK>/</BLINK></FONT>\n"; } } echo "</PRE></TD></TR>\n"; } echo "<TR>\n"; echo " <TD>sqlstate=" . $err["sqlstate"] . "</TD>\n"; if ($err["errlin"] != -1) echo " <TD>errlin=" . $err["errlin"] . "</TD>\n"; if ($err["errcol"] != -1) echo " <TD>errcol=" . $err["errcol"] . "</TD>\n"; if ($err["rowcount"] != 0) echo " <TD>rowcount=" . $err["rowcount"] . "</TD>\n"; echo "</TR>\n"; echo "</TABLE>\n"; } if (!sesam_connect ("mycatalog", "phoneno", "otto")) die ("cannot connect"); $stmt = "SELECT * FROM phone\n". " WHERE@ LASTNAME='KRAEMER'\n". " ORDER BY FIRSTNAME"; if (!($result = sesam_query ($stmt))) PrintReturncode ($stmt); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > See also: <A HREF="function.sesam-errormsg.html" ><B CLASS="function" >sesam_errormsg()</B ></A > for simple access to the error string only </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.sesam-connect.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sesam-disconnect.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >sesam_connect</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.sesam.html" ACCESSKEY="U" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sesam_disconnect</TD ></TR ></TABLE ></DIV ></BODY ></HTML >