Re: [PHP]Annoying Problem
Most likely die() is the problem.
Re: [PHP]Annoying Problem
What's with the die() at the end of your else statement?
Does it have a purpose? I'd take that out for starters.
And your - if($row) {.. - should be more descriptive.
Maybe try saying - if(isset($row)) {.. - or - if(strlen($row)>0) {.. -
Also, when I select from a query, I always use while().
Maybe, instead of if($row), you can try while($row).
Try something like this:
PHP Code:
<?php
$action1 = $_POST['action1'];
$action2 = $_POST['action2'];
$action3 = $_POST['action3'];
$action4 = $_POST['action4'];
$action5 = $_POST['action5'];
$hour1 = $_POST['hour1'];
$hour2 = $_POST['hour2'];
$hour3 = $_POST['hour3'];
$hour4 = $_POST['hour4'];
$hour5 = $_POST['hour5'];
$keyid = $_POST['keyid'];
if(isset($keyid)) {
mysql_connect("localhost", "ashin951_keydb", "***") or die(mysql_error());
mysql_select_db("ashin951_keydb") or die(mysql_error());
$query = "SELECT * FROM community WHERE id='$keyid'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result) or die(mysql_error())) {
echo "<h3>Is this Correct?</h3><br><br><b>Id Number:</b> ";
echo $keyid;
$name = $row['name'];
echo "<br><b>Name:</b> ";
echo $name;
echo "<form action=\"login2.php\" method=\"post\" name=\"login2\">
<input name=\"action1\" type=\"hidden\" value=\"$action1\">
<input name=\"action2\" type=\"hidden\" value=\"$action2\">
<input name=\"action3\" type=\"hidden\" value=\"$action3\">
<input name=\"action4\" type=\"hidden\" value=\"$action4\">
<input name=\"action5\" type=\"hidden\" value=\"$action5\">
<input name=\"hour1\" type=\"hidden\" value=\"$hour1\">
<input name=\"hour2\" type=\"hidden\" value=\"$hour2\">
<input name=\"hour3\" type=\"hidden\" value=\"$hour3\">
<input name=\"hour4\" type=\"hidden\" value=\"$hour4\">
<input name=\"hour5\" type=\"hidden\" value=\"$hour5\">
<input name=\"keyid\" type=\"hidden\" value=\"$keyid\">
<input name=\"check\" type=\"hidden\" value=\"1\">
<input name=\"yes\" type=\"submit\" value=\"Yes\">
<input name=\"no\" type=\"button\" value=\"No\" onClick=\"history.go(-1)\">
</form>";
}
if(strlen($name)<1) {
echo "Id does not exist. Please try again.";
}
} else {
echo "No Id entered. Please try again.";
die();
}
?>
<title>Verify Information</title>
This should find out if the ID was submitted. If it was, it will try connecting, else, give error message. I left your die(); message at the very end. That shouldn't be the problem, but it will break the page after the error message if there is no ID submitted.
Hope this can help
Re: [PHP]Annoying Problem
i used die a lot and it didnt effect my script.
i tried your script you gave me and its still the same.
heres something strange, when i didnt type an id in, nothing showed up.
edit: i found your problem, you have to make if($_POST == ""
or something like that, since we gave it a variable in the beginning, if it was blank it is still set.
edit: i think people think that this problem is solved. it's not. =]
Re: [PHP]Annoying Problem
still need some help. i couldnt figure out what the problem is.
oh crap i double posted.
Re: [PHP]Annoying Problem
Ok I didn't get what you wanted at first. But now I think I know.
You want to say (ID does not exist) if the user types in a random, non-existing ID, right?
You can do that by doing this:
PHP Code:
while($row = mysql_fetch_array($result) or die(mysql_error())) {
echo "<h3>Is this Correct?</h3><br><br><b>Id Number:</b> ";
echo $keyid;
//calculate total
if(strlen($total)<1) {
$total = 1;
else {
$total++;
}
$name = $row['name'];
echo "<br><b>Name:</b> ";
echo $name;
After you close the while curly, type this:
PHP Code:
<?php
if(strlen($total<1) {
echo "<p>No IDs found</p>";
}
?>
I use this to display the total # messages/friend requests on my profile thing.
I would normally display how many things were loaded total after this,
PHP Code:
<?php
if(strlen($total<1) {
echo "<p>No IDs found</p>";
} else {
echo "<p>Total IDs: $total</p>";
}
?>
Re: [PHP]Annoying Problem
well first, why use strlen when you can just if($total == "") {.
umm, and i wasnt sure what your code said until i reread it over and over again.
what i want my script to do is basically look in the database and check if the keyid matches with the keyid in my db and then take out the name. and if the keyid does not exist, then show a no id found thing.
edit: i fixed my problem. i used
PHP Code:
if (mysql_num_rows($result) != 1) {
instead. i found it in one of my other scripts that were working and seemed like the place to use it. thanks for helping. =]