I have a simple script that gets 2 variables from the url and runs a query to make sure they are in the Database.
This works and the mysqli_num_rows returns "1" as expected.
I then use an IF statement, IF rows = 1, do this... OR, IF rows = 0, do this...
But 90% of the time (not every time), it will run whatever is in both IF statements?!? Here is my code:
$_GET['submit'];
$ID = $_GET['ID'];
$Code = $_GET['Code'];
$query = mysqli_query($conn, "SELECT * FROM Holding WHERE id = '$ID' && idCode = '$Code'");
$RowCountQuery = mysqli_num_rows($query);
$rowDetails = mysqli_fetch_array($query);
if ($RowCountQuery == "1")
{
if($rowDetails['type'] == "user")
{
// Add to user Table
//Remove from Holding DB
header("location:Thankyou.php");
}
if($rowDetails['type'] == "advertiser")
{
// Add to advertiser Table
//Remove from Holding DB
header("location:Thankyou.php");
}
}
elseif ($RowCountQuery == "0") {
header("location:verifyError.php");
}
Can anyone see where i've gone wonky? As I thought it should be fine, and does work now and then? The script correctly adds the info to the user or advertiser table, but then redirects me to the verifyError.php?!? Help, there's only a few strands of hair left on my head!
I have also used $RowCountQuery = 1 and $RowCountQuery = 0 formats which had the same result
Aucun commentaire:
Enregistrer un commentaire