id for row update not working??

admin

Administrator
Staff member
hello again sorry to trouble you all..
its just that the follwoing code works...
view the working page on <!-- w --><a class="postlink" href="http://www.worldrallying.com/x_db_addfull.php">www.worldrallying.com/x_db_addfull.php</a><!-- w -->
___________________________________

<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>

_________________________________
however now i have modified the code so it updates to a specific row as seen now..
<!-- w --><a class="postlink" href="http://www.worldrallying.com/x_db_addfull_id.php">www.worldrallying.com/x_db_addfull_id.php</a><!-- w -->
buti get an error and i just cant see where i have gone worng??
if anyone could let me know where the fault is in the new code below, it would be very very much appreciated...
<!-- 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 = " UPDATE news ( title, descrip )
SET ( '$title', '$descrip')
WHERE ID=2 ";
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>
 
Back
Top