RussellReal
Members-
Posts
1,773 -
Joined
-
Last visited
Everything posted by RussellReal
-
ok I hope you understand what I'm about to say.. in `basket` you're going to need an auto_incrementing id field THEN in the basket php when you're showing the user what he has in his basket.. have the delete button send the item's ID to another php file like.. deleteItem.php?id=10 then in deleteItem.php you get the user's id from the cookie or session and do something like this <?php $id = (int) $_GET['id']; $sql = "DELETE FROM `basket` WHERE `id` = '{$id}' AND `user_id` = '{$_SESSION['user_id']}'"; mysql_query($sql); ?>
-
date() and used while loop to iterate and get users
RussellReal replied to scrubbicus's topic in PHP Coding Help
use http://us2.php.net/manual/en/timezones.america.php to find the closest american timezone -
and then if sum1 votes it 1 then it'll be a rated 3 game.. its about the public.. ofcourse the first rating will be a substantial one.. but whgen other users rate it thats what will build its rating also its the only way to do it rofl
-
idk C but you could try ip2long but don't take my word for it I just googled the reference for htonl lol and these two pretty much match up :S
-
ok... lol make choices 1..2..3..4..5 then, when sum1 clicks 5.. add it to the total number like if 1 user clicked 2 and sum1 licked 4 you'd have 2 votes which total 6 points now if you divide 6 by 2 you get 3 which is the AVERAGE rating of whatever content they're rating.. so the content's rating would be 3 so basically this format RATING = TOTAL_SCORE / TOTAL_VOTES
-
mysql_insert_id
-
Backticks are only mysql specific I believe so if your looking to write proper / portable sql I would not recommend using them at all. even so, its still a good idea for example using spaces in table names or field names.. and also if you're going to move from MySQL to another SQL engine, you've seriously got hundreds of other things to change.. for example.. mysql_connect.. mysql_query I'm sure you could do // sql.php $connector = "mysql_connect"; $query = "mysql_query"; $db_select = "mysql_select_db"; $escape = "mysql_real_escape_string"; and then use those variables as functions in your script and change those function names when your port over to a new SQL engine/program.. but I'm sure 98% of the people don't do that and will most likely have to go over al their code in the future anyway.. and backticks make the code look so much neater.. and makes it more flexible
-
I look at php.net all the time for functions I've used hundreds of times.. because its hard to remember the argument places of every function, the object to learning a language is just know which functions do what.. and remember the workings of every function that you use on a consistent basis.. other functions that you use once in a blue moon, why waste precious brain space to remember every aspect about it when there is php.net and countless other php references to use.. so, the best website in MY opinion http://php.net Other great websites: http://w3schools.com/ http://tizag.com/
-
remove the wheres lol
-
date() and used while loop to iterate and get users
RussellReal replied to scrubbicus's topic in PHP Coding Help
if you're on shared hosting you most likely don't have access to the php.ini so you'd have to use date_default_timezone_set in each php script you have that uses date. if you do have access to php.ini try ini_set setting the value of 'date.timezone' to your timezone.. -- Either way lol, both work the same way.. You could open up the php ini manually and change it and save it permanently.. but only if you have access.. -
well the only thing I can see wrong with this is different character encoding, has different positions for the character for example, 32 would be the charCode for UTF-8 for a space, and 160 would be a non-breaking space in UTF-8, meanwhile in chinese they may have characters like this, like a b c, but I am not 100% positive, but I'd assume they'd be at different positions on that encoding.. and when everything boils down to it, everything is broken down to the asc value of the character in question although I'm not completely positive about any of the above, thats just about what I figure how happens, which would explain the ucfirst() failure and ereg failure to match the letters
-
what that is saying is that the file doesn't exist.. its trying to open the file from the base directory of your server.. not the base directory of the website.. try removing the first / in the filename.. you're looking for /sitev2/filename.html instead of /var/www/htdocs/sitev2/filename.html also its good to add, that fopen does not create a directory.. it may attempt to create a file depending on the mode you opened the file with (second parameter of fopen()). so since you're looking INSIDE of a DIRECTORY which doesn't exist.. the file isn't being created since the directory doesn't exist, therefore your php throws the error you're encountering
-
!function() !true ! will flip the condition its like != NOT EQUAL when you have a single condition in a conditional the if is waiting for a value which evaluates to TRUE now, if you do !whatever it will tell the if statement to wait for any value which evaluates to false, for example.. if (!true) { } the conditional will be false since it is expecting to turn a false value into true.. and, writing proper is usually more keystrokes.. writing short hand will always save you time.. like using SELECT * FROM tabName WHERE field = 'value' but the PROPER syntax for that would be SELECT * FROM `tabName` WHERE `field` = 'value' you need to decide if being proper is worth the extra keystrokes..
-
[SOLVED] IMPORTANT --- ERROR MESSAGE MAKING ME FEEL STUPID
RussellReal replied to kaimason1's topic in PHP Coding Help
pfm is right, use ` ` instead of ' ' -
hello again bro try doing session_start() before you include the files.. then just use $_SESSION inside the functions because in order to fill the $_SESSION superglobal you need to actually start the session otherwise $_SESSION will not be present..
-
readdir
-
Check All function and Checkbox array conflict
RussellReal replied to dasein's topic in PHP Coding Help
you can utilize javascript's "node" functions for example if you added in an id for those forms lets say you id'd one 'test' you could do function checkAll(eid) { var children = document.getElementById(eid).childNodes; for (i = 0; i < children.length; i++) { children[i].checked = true; } } -
telling the program that this is the first opening of page
RussellReal replied to ms1990kl's topic in PHP Coding Help
<?php session_start(); if (!isset($_SESSION['first'])) { // load defaults here $_SESSION['first'] = 1; } ?> -
if(($var == true && $var2 == false) || ($var3 == true || $var4 == false)){ } could be turned into: if ((($var == true) && ($var2 == false)) || (($var3 == true) || ($var4 == false))) { } or even: if ((($var) && (!$var2)) || (($var3) || (!$var4))) { } second or third would be considered neater
-
Create and Query XML document in Cache?
RussellReal replied to jeff00seattle's topic in PHP Coding Help
http://php.net/xml -
its always a good idea to nest your conditionals.. if you think about it.. if you had a neatly organized file cabinet you'd be able to find the paper you need faster.. than if you had all the papers in a pile and you have to use extra power to look through all of the papers.. being neat is always looked @ by employers as well..