Hey guys. This is driving me crazy. I can't see any code problems and I had another friend look and neither can he. EVERYTHING works PERFECTLY...all echos work right and everything and no errors get returned..the problem is $query4 and $query5 appear to do nothing..though i get no error..i get nothing pnput to the database either! i put a bunch of notes in the code so it would be easier to follow. thanks for the help ion advance.
<?php
include 'logincheck.php';
include 'document_type.php';
// get and/or set variables
$last_name=$_GET['item1'];
$first_name=$_GET['item2'];
$story_title=$_GET['item3'];
$chapter=$_GET['item4'];
$subchapter=$_GET['item5'];
$new=$_GET['item6'];
$credit=$_SESSION['username'];
// change story title to all lowercase and remove spaces
// then assign to another variable used to determin which table to use
if (!$function_check) {
$function_check = true;
function clean($string) {
$non_alphanumeric_chars = "/([^a-zA-Z0-9_])/";
$string = preg_replace( $non_alphanumeric_chars, "", $string );
$string = strtolower($string);
return $string;
}
};
$clean_title = clean($story_title);
// log in to database
$username="**********";
$password="***********";
$database="**************";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
// Check to see if this name is already in the database with a value of yes in the 'first' column
$query1="SELECT recnum FROM mastercharacterlist WHERE lname='$last_name' AND fname='$first_name' AND first='yes'";
$result1=mysql_query($query1) or die(mysql_error());
mysql_close();
if (mysql_num_rows($result1) > 0)
// if $query1 returned a result then we go to the nested statements
{
$record_number1=mysql_result($result1,0,"recnum");
if ($new=="yes")
{
//if the userinput that was retrieved via $_GET is yes then run this code
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query2="SELECT * FROM basicinfo WHERE recnum='$record_number1'";
$result2=mysql_query($query2) or die(mysql_error());
$n1=mysql_result($result2,0,"storyname");
$n2=mysql_result($result2,0,"chapter");
$n3=mysql_result($result2,0,"chapter_id");
echo'
'.$first_name.' '.$last_name.' has already been entered as having thier first appearance in '.$n1.' Ch. '.$n2.''.$n3.'.
This character will not be entered at this time. Please make the appropriate corrections and try again.
';
mysql_close();
}
else
{
// if the userinput that was retrieved via $_GET is no then run this code
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query3="SELECT recnum FROM basicinfo WHERE storyname='$story_title' AND chapter='$chapter' AND chapter_id='$subchapter'";
$result3=mysql_query($query3);
$record_number3=mysql_result($result3,0,'recnum');
mysql_close();
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query4="INSERT INTO $clean_title (recnum,lname,fname,first,credit) VALUES ('$record_number3','$last_name','$first_name','$new','$credit')" or die(mysql_error());
echo'
The following data has been entered:
<br>
'.$first_name.' '.$last_name.'
<br>
'.$story_title.'
<br>
Chapter '.$chapter.''.$subchapter.'
<br>
New character? '.$new.'
';
mysql_close();
}
}
else
{
// if the value of $query1 was NOT yes...then this is the code to run regardless of what the $new variable is
$record_number1=mysql_result($result1,0,"recnum");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query5="INSERT INTO $clean_title (recnum,lname,fname,first,credit) VALUES ('$record_number1','$last_name','$first_name','$new','$credit')" or die(mysql_error());
echo'
The following data has been entered:
<br>
'.$first_name.' '.$last_name.'
<br>
'.$story_title.'
<br>
Chapter '.$chapter.''.$subchapter.'
<br>
New character? '.$new.'
';
mysql_close();
}
// ending menu
echo'
<br><br><a href="character_input_last_name.php" class="linkstyle1">Return to Character Input</a>
<br><a href="index.php" class="linkstyle1">Return to Main Timeline</a>
';
?>