Below is the code I used to try to insert info into a mysql database, the
form posts to itself. After I hit the submit button it isn't echoing the
indication that information has been added, and when I check the database
there isn't anything there. help please!

    $usr = "username";
    $pwd = "password";
    $db = "dbname";
    $host = "localhost";

    # connect to database
    $cid = mysql_connect($host,$usr,$pwd);
    if (!$cid) { echo("ERROR: " . mysql_error() . "\n");    }

   <TITLE>Insert Link</TITLE>


<P><FONT SIZE=5><B> Add Link </B> </FONT></P>

    if ($REQUEST_METHOD=="POST") {

        $description = str_replace("'","''",$description);
        $sitename = str_replace("'","''",$sitename);

        $SQL = " INSERT INTO links ";
        $SQL = $SQL . " (category, sitename, siteurl, description) VALUES ";
        $SQL = $SQL . " ('$category', '$sitename','$siteurl','$description')

        $result = mysql_db_query($db,"$SQL",$cid);

             if (!$result) { echo("ERROR: " . mysql_error() .
$SQL\n");    }

        echo ("<P><B>New Link Added</B></P>\n");



<FORM NAME="fa" ACTION="insert.php" METHOD="POST">
<TR><TD><B>Category: </B> </TD><TD><INPUT TYPE="text" NAME="category"
<TR><TD><B>Site Name:</B> </TD><TD><INPUT TYPE="text" NAME="sitename"
<TR><TD><B>Site URL: </B> </TD><TD><INPUT TYPE="text" NAME="siteurl"
VALUE="http://"; SIZE=40></TD></TR>
<TR><TD VALIGN=TOP><B>Description: </B> </TD><TD> <TEXTAREA
NAME="description" ROWS=5 COLS=40></TEXTAREA></TD></TR>
<TR><TH COLSPAN=2><P><INPUT TYPE="submit" VALUE="Add Link"></P></TH></TR>

<?    mysql_close($cid); ?>

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to