AyKay47
Members-
Posts
3,281 -
Joined
-
Last visited
-
Days Won
1
Everything posted by AyKay47
-
there are several things wrong with this code, and I am amazed that this is the only error that you are receiving. 1. you have an extra semi-colon in your SQL, it should read. $match = "select user_id from $table where username = '$_POST['username']' and password = '$_POST['password']'"; 2. note: using the context "or die(mysql_error())" should only be used in the developmental stages of coding. Once the site is ready to be live, a new error handling method should be created. 3. mysql_num_rows cannot return a negative value, so checking if mysql_num_rows is negative is not needed, you can simply write: if ($num_rows == 0) 4. (this should be the first check), you should always check to make sure that $_POST values are set by using isset before using them in your code. if(isset($_POST['username'], $_POST['password'])) 5. user input validation is a must before attempting to use the values in a query, as your code is right now, it is wide open to SQL injection. mysql_real_escape_string should be used at the least. 6. again, you are attempting to use a $_POST value ($_POST['remember']) before checking to make sure that it is set. You are also using strip_tags() on the value, and then checking for its existence, which logically makes no sense. 7. the first 2 cookies in theory should be ok. However the third one would cause trouble, since you are attempting to store a resource returned from mysql_query() into a cookie, which again, logically makes no sense. If you are attempting to store a value grabbed from the query, then use a mysql_fetch function to grab the values. mysql_fetch_assoc 8. $HTTP_COOKIE_VARS is deprecated and should not be used, use the superglobal array $_COOKIE instead. http://www.php.net/manual/en/reserved.variables.cookies.php 9. judging from the header, you expect $site_userid to have the value of user_id grabbed from your query as its value, thus $_COOKIE['mysite_userid'] as well, if this is the case, refer to answer 7.
-
Programming Assignment 2, Thank you PHPFreaks!
AyKay47 replied to MasterACE14's topic in Miscellaneous
well done! -
from the given form, I do not see an input value with name='couponcodenumber', which means $_POST['couponcodenumber'] will never exist, and never equal $some_other_value (we have no clue where $some_other_value is coming from either). That being said, the correct $_POST index, according to your code, should be $_POST['CouponCode']: $coupon_code = $_POST['CouponCode']; if ($coupon_code == $some_other_value) { header ("Location: specialordersDiscountForm.php"); exit(); } else { header ("Location: specialorderwrongcode.php"); exit(); }
-
Andy-H is correct, I ran your code through JSLint (a rather handy tool to quickly review javascript code) and it outputtued this error: Problem at line 14 character 32: Unexpected '&'. if(inputUser.attr("value") &&amp... frankly, that snippet of code doesn't make sense. Also as noted, there are browser tools to help you debug your JavaScript code. Developer tools for chrome (as Andy-H noted), and the firefox add-on "firebug". Edit: also, Andy-H provided the correct syntax for the if statement.
-
http://api.jquery.com/jQuery.ajax/ what makes a refresh so bad in this situation? agreed.
-
yes this can be done with ajax if you want to do it asynchronously, PHP if it doesn't need to be asynchronous. http://api.jquery.com/jQuery.ajax/
-
along with the link that you shared earlier, this is a very interesting read. I had not known about the "leap second". thank you for the information.
-
getting php to work with relationship tables
AyKay47 replied to DonaldFaulknor's topic in PHP Coding Help
collectively, I'm going to say that you should be studying more about Mysql and PHP before attempting to make the next Facebook like 100000000 other programmers. Study hard, learn, and then come back and attempt to make this kind of website the correct way. -
getting php to work with relationship tables
AyKay47 replied to DonaldFaulknor's topic in PHP Coding Help
lol.. -
It's not. That was my point. leap second..really
-
getting php to work with relationship tables
AyKay47 replied to DonaldFaulknor's topic in PHP Coding Help
WHERE friend_id=$_SESSION['user_id'] -
A day is never 145440 seconds, it is 86400 seconds. That's what I get for posting before I have my coffee. Where did that number come from? Seriously. 1.68 days then went on to say that 86400 seconds is not always a day, lol
-
round is risky because of the gray area between rounding up and down. how is rounding to the hundredths place any more risky then multiply the number by 100? Maybe I am wrong, but if multiply by 100 and truncate after the dot, I get exactly the same digits as was in the source. I am not sure what would round do if the exact result should be 14.055 and the user types 14.05. would it round the same? One thing is sure - if I multiply both by 100 and truncate, the result would be 1405 for both. alright, don't listen to me, what do I know anyway, go for it. multiply the numbers by 100, problem solved.
-
round is risky because of the gray area between rounding up and down. how is rounding to the hundredths place any more risky then multiply the number by 100?
-
strtotime() returns a unix timestamp, which is what the integer that you are receiving is, to convert it into the proper format, use date
-
while ($row_hotels_select = mysql_fetch_assoc($hotels_select)); $rows = mysql_num_rows($hotels_select); if($rows > 0) { mysql_data_seek($hotels_select, 0); $row_hotels_select = mysql_fetch_assoc($hotels_select); } this is your problem, you are using mysql_data_seek statically inside of a loop, this is a no no as it will consistently reset the result pointer to the first row. Typically, this function is used to return the current row pointer and display it. Really, all that is needed is this: if($hotels_select) { while ($row_hotels_select = mysql_fetch_assoc($hotels_select)) { $rows = mysql_num_rows($hotels_select); ?> <option value="<?php echo $row_hotels_select['est_town']?>"<?php if (!(strcmp($row_hotels_select['est_town'], $row_hotels_select['est_town']))) {echo "selected=\"selected\"";} ?>><?php echo ucwords(strtolower($row_hotels_select['est_town']))?></option> <?php } } ?>
-
there are several different types of inputs, the one that allows a user to fill in the field with whatever data if type='text' (assuming we aren't including textareas). if you want to validate the user data in real-time before they submit, javascript would be required. once the user submits, you can compare the data however you want and return whatever feedback you want. also, why not simply compare the floats?
-
getting php to work with relationship tables
AyKay47 replied to DonaldFaulknor's topic in PHP Coding Help
Exactly, OP I will say this one more time before leaving this thread, the query seems to be working as expected probably because you only have a few people in your db table. However once you add more members etc you will quickly find that this query is faulted. The main search needs to connect the statuses of the friends of the session owner, which means that needs to be included in the where clause. If you are going to do something, do it correctly the first time, don't just say "hey it seems to be working". Test it thoroughly. -
You aren't getting any results because you are not returning/outputting anything from the function.
-
use a foreach statement to add a record to a table
AyKay47 replied to jeff5656's topic in PHP Coding Help
no, it has to do with mysql http://dev.mysql.com/doc/refman/5.1/en/insert.html -
as stated, this is a bad practice as it can lead to pollution down the road. Any value that your method needs should be brought in via its parameter list, not globally.
-
getting php to work with relationship tables
AyKay47 replied to DonaldFaulknor's topic in PHP Coding Help
the where clause is what row from the left table the query will actually grab, the join simply joins columns onto the main search however you tell it to with the ON clause. I am assuming that you would want friend_id equal to the user of the current session. -
getting php to work with relationship tables
AyKay47 replied to DonaldFaulknor's topic in PHP Coding Help
well, you will definitely want to use a mysql JOIN to connect the data from both tables, perhaps something like: select status.statuses, status.when, status.user_id from friends join status on status.user_id = friends.friend_id where friend_id = $_SESSION['user_id'] to get you started -
from the manual: do you have access to the php.ini file?