-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
Using a database to store username/password combinations is the most common way to do what you are trying to do. I have to ask why exactly you aren't using some sort of database software. the reason strcmp always returns true, is because it returns <0 number when the first argument is shorter than the second, and >0 if the second argument is shorter than the first (and 0 if they are equal) Assuming you are entering a sername and password combo that doesn't exist in the database, it will always be true because non 0 integers convert to boolean true. see strcomp: http://php.net/manual/en/function.strcmp.php boolean casting: http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
-
Your code is working as intended. You ask PHP to display (among other things) the name of the uploaded file with this line <?php echo $_FILES['pic']['name']; ?> if you wanted your browser to render an image, you would need to tell it to do so with an img tag. There are a few steps that you must take before you can do this though (like moving the file from the temporary directory where all uploaded images are stored). I suggest you continue reading the manual entry, and a few other file uploading tutorials if needed.
-
while loop to pick a certain type from db??
mikesta707 replied to rdkd1970's topic in PHP Coding Help
No i mean the form that is supposed to be posting the $_POST information -
Oh i see, so you are using the lowercased PW's from the DB and the uppercased PW's from some form of input. You could always use the strtolower() function to convert all your password strings to lower case.
-
theoretically that would work yes. Have you tried it? Also realize running queries in a loop isn't a very good idea, and as your website/userbase scales, that script will become more and more demanding on your server resources.
-
i dont really see anywhere in that code that passwords have to be uppercase. In your first function, everything depends on your two input arguments, and regardless of if they are uppercase, or lowercase, they have to be the same for the function to return true. if you need to convert something to uppercase though, use the toupper function. Similarly, to convert to lowercase, there is a tolower function
-
while loop to pick a certain type from db??
mikesta707 replied to rdkd1970's topic in PHP Coding Help
So now the problem will be to see why your post variable is empty. Are you sure it has the right name? Can you post the code for the form that is sumbitting that post data? Try doing a print_r on $_POST and see if it is structured like you expect it to be -
well of course it does. You have it set to execute as long as cookie is not equal to 1. This means that as long as its not 1, it will keep executing, and since you keep incrementing it, if it goes above one it will execute indefinitely. WHen you set it to 0, it executes once, becomes 1, then stops. However, if you set it to anything >= 1, it will always become greater than 1 at the end of the loop, even in the first execution of the do block, and execute endlessly What exactly are you trying to do? How many times do you want this loop to execute given a certain amount of cookie to start?
-
while loop to pick a certain type from db??
mikesta707 replied to rdkd1970's topic in PHP Coding Help
try echoing your $_POST['looking_for'] variable and see what it has in it. I suspect it is empty -
why not just print $this->results inside your getResults function before it prints the other stuff? Alternatively, you could have your getResults function return a string with the output instead of printing it. This is probably the better option. Then you can do $str = $Search->GetResults('foo'); $res = $Search->results; and use these variables whenever you need, instead of being forced to use the output when you call them.
-
um.. change your $user variable to Admin and your $password variable to password? Before you do this though, I suggest you read up a little more on PHP/Mysql
-
why don't you reverse the two operands? Seems like you should be subtracting total paid from points, not the other way around. Also, a negative value can make sense assuming you let people "over withdraw" or go into debt
-
just negate the while condition?
-
onclick is a client side event caught by client side languages like javascript. PHP can't do anything with an onclick event.
-
1. yes that is correct, though you may only need to do $name=ucwords($name). 2. Yes, there are quite a few ways. You can use regex if you wanted to, but I would suggest the built in function is_numeric(). You can use this like so if (!is_numeric($_POST['some_input'])){ die ("invalid input into 'some_input' form field"); } of course you want a more graceful way of handling these kind of errors, but you get the idea. 3. If you wish to check that all forms are filled in BEFORE a form submit, you need javascript. Specifically, you need to research into how Javascript accesses the HTML DOM.
-
is the absolute value of that difference the current balance? if so use the abs() function. This takes the absolute value of the input argument. $currentbalance = abs($row['totalpaid'] - $row['points']);
-
um, what information are you trying to get and what does your script have to do with it? Do you need some information from the here table? Your problem is unclear and as such, I can not offer any help
-
oh my mistake, I was under the impression that $tag was an array key instead of an array value for some reason. Don't worry im pretty tired also. My point still stands that he could simply use array_count_values to make the foreach irrelevant, and that OP making this counter variable an empty array seems to suggest that his intent for that variable is unclear. It really doesnt matter in the long run
-
yes doing 1 query is far better and far easier on your system then doing 31
-
you have your print_r inside the while loop, so its showing you how your array is building as the while loop executes. Try taking print_r out of the while loop, and placing it after, and see if it prints what you expect
-
NULL doesn;t catch empty strings (which your variables are. Empty string and NULL and NOT the same thing.) Try using empty() as in if (empty($date)) $date="0000-00-00";
-
yes in the context, since OP used explode, which will return a numeric array, array_key_exists will always be true.
-
You can use nested foreach loops to loop through a multidimensional array. FOr example foreach( $events as $row){ //now going through each row. This is basically the array of each days event info foreach($row as $column){ //now we have each individual piece of information on the event } } hope this helps
-
Code works fine in PHPMyAdmin but doesn't work in PHP
mikesta707 replied to Gotharious's topic in PHP Coding Help
It appears you are redefining the getHotel method. Without seeing the current code I can't be of much help, but If you look in your code, and you find getHotel defined twice, you should delete the oldest version of the function. -
Code works fine in PHPMyAdmin but doesn't work in PHP
mikesta707 replied to Gotharious's topic in PHP Coding Help
No problem. I'm a tutor, so I get a lot of practice explaining programming problems in a simplistic way. If your thread is resolved, you can click the topic solved button at the bottom of the thread