PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if ($result == FALSE && $sendvalue){
($message .= "<p class="error">Please import database first.</p>");
}else if (!$_REQUEST['com'] && $sendvalue && $result == TRUE){
($message .= "<p class="error">You forgot to make your selection.</p>");
}else if ($_REQUEST['com'] == 'back' && $result == TRUE){
($message .= "<p>All filenames have been changed to original values.</p>");
}else if ($_REQUEST['com'] == 'update' && $result == TRUE){
($message .= "<p>All filenames have been changed to new, random values.</p>");
}else if ($_REQUEST['com'] == 'db_import' && $result == TRUE){
($message .= "<p>Initial values have been inserted into database.</p>");
}else{
($message .= "<p>Please make your selection below:</p>");
}
$result is simply a mysql_query so if it fails it thinks the db table has not been created yet and tells you to select the database import choice in the form below.
This part works great, the table is imported properly but after it's imported, it should tell you that "Initial values have been inserted into database." Instead it still tells you that you need to import the table.
But then when you refresh the page once more it works as it should have before the one extra refresh. I am sure there is a bug in the code above somewhere but I can't find it...
Thanks as always
Tomas
Last edited by tomfra on Sun Jul 04, 2004 2:22 pm, edited 1 time in total.
Right before this line:
if ($result == FALSE && $sendvalue){
Check the value of $result, if it's FALSE after doing the import then the if/else code block is working as expected and the problem must be where the assignment of $result takes place.
var_dump($result);
When you 'do something' and it takes a refresh to see the results of 'doing something' then that's just down to a code flow/logic problem in 99% of cases, so i still think your if/else is good (though slightly ugly )
$query = "SELECT * FROM `{$tb_prefix}_filenames`";
$result = @mysql_query($query);
The 3rd argument in update - $echo, is there just for debugging and $back returns everything to original values.
To markl999 & phice: I know this code looks ugly and you haven't seen the remaining 200 lines I have bad coding habits because I am learning php mainly from forums and a lot of those people who post there have bad coding habits so I "copy" those bad habits. It's not easy to get rid of it...
The problem with the elseif statement seems to be that after the import $result returns false while it should return true. I know it has something to do with the flow of the code but I still know so little about php or coding in general that I wonder when something I create does indeed work But I am learning...
Tomas
Last edited by tomfra on Sun Jul 04, 2004 1:33 pm, edited 1 time in total.