well, there were couple of typos in that post, and i thought you might notice them.
but anyway, i have changed it here:
(i am in doubt that if there is only 1 result from INSERT, then we dont need for loop to retrieve the record, if not then put a for loop around $valid_user_id = $user_record->user_id; and similar to others. But first try the following).
thanks....
<?php
if($submit) {
if ($textus != '' && $person != ''){
$sybase = sybase_connect("a" , "b" , "");
sybase_select_db("c");
$get_sql = sybase_query("SELECT * from user WHERE Login = '$person'");
$num_of_rows = @sybase_num_rows($get_sql);
// if returned number of rows are less than 1, then
// user doesnt exist in your table.
if ($num_of_rows < 1) {
sybase_close();
echo 'sorry your user name is wrong"';
exit();
}
$user_record = @sybase_fetch_object($get_sql);
$valid_user_id = $user_record->user_id;
$update_query = sybase_query ("INSERT INTO news (user_id, Available, Updated, Created)
VALUES ('$valid_user_id', 'J', 'default', 'default')");
// now the problem is to get the news_id, to insert in newstext table
// this is what we need to check for foreing keys. but for now, i am
// just getting the last row of the table, hopping its the one you
// just added above!
$get_news_id ("SELECT * FROM news GROUP BY news_id DESC LIMIT 1");
// above query gets the news_id, first by sorting the table
// records in descending order. so the first record is the last one.
$get_last_news_id = @sybase_fetch_object($get_news_id);
$last_news_id = $get_last_news_id->news_id;
$insert_newstext = sybase_query ("INSERT INTO newstext (news_id, text) VALUES ('$last_news_id', '$textus')");
sybase_close($sybase);
print "<p>Thank you!";
print "<br><br> Your text has been submitted!";
}
else {
$error = " Sorry! You didn't fill in all fields!";
}
}
?>
<head><title>input</title></head>
<body>
<P>
<form method="post" action= <? $php_self ?> >
FIELD1: <input type="Text" name="person"> <br>
FIELD2: <textarea name="textus" rows=15 cols=72 wrap=HARD></textarea><br>
<input type="Submit" name="submit" value="Enter Information"><INPUT TYPE=RESET VALUE="Reset Information">
</form>
</body>