Ray, Here is are the errors I get using the folloiwng code: Again, this works but I get the error messages. Also, the insert uses the auto number of 1289 instead of the correct auto number which the next insert should be 89. Not sure why but I can live with that I guess. I do konw how to reset the auto increment but that's not the issue. Thx Mike
Hi Ray. Thx for sending. I tried to run what you sent and it loads fine but the query still doesn't work. I added a bracket after the line ($result = mysqli_query($connect, $query);). Once I added the bracket the query works how I want it to work. However, the page does not load properly. It will load but I get an error message at the top of the page. Undefined variable result on line 31. Line 31 is the line with the if (mysqli_num_rows($result) == 0) {. Also, I get the error
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp64\www\registry\Admin\players\playersInsert.php on line 31
Here is the code I'm using that is working properly with the error on load
<?php
//check.php
if(isset($_POST["Insert"])) {
$player_name = mysqli_real_escape_string($tsrbase, $_POST["player_name"]);
$grad_year =mysqli_real_escape_string($tsrbase, $_POST["grad_year"]);
$query = "SELECT * FROM players WHERE player_name = '".$player_name."'AND grad_year = '".$grad_year."' ";
$result = mysqli_query($tsrbase, $query);
}
if (mysqli_num_rows($result) == 0) {
if (isset($_POST["Insert"]) || isset($_POST["Insert_x"])) {
$InsertQuery = new WA_MySQLi_Query($tsrbase);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "players";
$InsertQuery->bindColumn("player_name", "s", "".((isset($_POST["player_name"]))?$_POST["player_name"]:"") ."", "WA_BLANK");
$InsertQuery->bindColumn("grad_year", "d", "".((isset($_POST["grad_year"]))?$_POST["grad_year"]:"") ."", "WA_ZERO");
$InsertQuery->saveInSession("WADA_Insert_players");
$InsertQuery->execute();
$InsertGoTo = "playersInsert.php?NewPW=Yes";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
}
?>