hey there...
i am having trouble updating a mysql DB with php.
i can add a new row of data but i really need to have in the code a fixed no for the row i.e. say 1 and any input on the webform will go to row 1 instead of adding to anew row each time...
the cod e i have is.....i cant get the syntax right for an update function
please help..... <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
__________________________________
<HEAD>
<TITLE>adding user info to DB</TITLE>
</HEAD>
<BODY BGCOLOR="#000099" TEXT="#FFFFFF" LINK="#0000FF" VLINK="#800080">
<?php
if ( isset($title ) && isset( $descrip ) )
{
// checking the input by the user
$dberror = "";
$ret = add_to_database( $title, $descrip, $dberror );
if ( ! $ret )
print "error: $dberror<BR>";
else
print "Thanx very much";
}
else {
write_form();
}
function add_to_database( $title, $descrip, $dberror )
{
$user = "****";
$pass = "*****";
$db = "******";
$link = mysql_connect("smtp2", $user, $pass );
if ( ! $link )
{
$dberror = "couldn't conekt to MySQL server";
return false;
}
if ( ! mysql_select_db( $db, $link ) )
{
$dberror = mysql_error();
return false;
}
$query = " INSERT INTO news ( title, descrip )
values( '$title', '$descrip')";
if ( ! mysql_query( $query, $link ) )
{
$dberror = mysql_error();
return false;
}
return true;
}
function write_form()
{
global $PHP_SELF;
print "<form action=\"$PHP_SELF\" method=\"POST\">\n";
print "<input type=\"text\" name=\"title\">";
print "the title u would like<p>\n";
print "<input TYPE=\"text\" name=\"descrip\"> ";
print "the description u wwnat to put in<p>\n";
print "<input type=\"submit\" value =http://www.phpbuilder.com/board/archive/index.php/\"submit!\">\n</form>\n";
}
?>
</BODY>
i am having trouble updating a mysql DB with php.
i can add a new row of data but i really need to have in the code a fixed no for the row i.e. say 1 and any input on the webform will go to row 1 instead of adding to anew row each time...
the cod e i have is.....i cant get the syntax right for an update function
please help..... <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
__________________________________
<HEAD>
<TITLE>adding user info to DB</TITLE>
</HEAD>
<BODY BGCOLOR="#000099" TEXT="#FFFFFF" LINK="#0000FF" VLINK="#800080">
<?php
if ( isset($title ) && isset( $descrip ) )
{
// checking the input by the user
$dberror = "";
$ret = add_to_database( $title, $descrip, $dberror );
if ( ! $ret )
print "error: $dberror<BR>";
else
print "Thanx very much";
}
else {
write_form();
}
function add_to_database( $title, $descrip, $dberror )
{
$user = "****";
$pass = "*****";
$db = "******";
$link = mysql_connect("smtp2", $user, $pass );
if ( ! $link )
{
$dberror = "couldn't conekt to MySQL server";
return false;
}
if ( ! mysql_select_db( $db, $link ) )
{
$dberror = mysql_error();
return false;
}
$query = " INSERT INTO news ( title, descrip )
values( '$title', '$descrip')";
if ( ! mysql_query( $query, $link ) )
{
$dberror = mysql_error();
return false;
}
return true;
}
function write_form()
{
global $PHP_SELF;
print "<form action=\"$PHP_SELF\" method=\"POST\">\n";
print "<input type=\"text\" name=\"title\">";
print "the title u would like<p>\n";
print "<input TYPE=\"text\" name=\"descrip\"> ";
print "the description u wwnat to put in<p>\n";
print "<input type=\"submit\" value =http://www.phpbuilder.com/board/archive/index.php/\"submit!\">\n</form>\n";
}
?>
</BODY>