-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
Just a though: I would do it the other way around... if users are logged in, I wouldn't show last activity time (since they're online, I assume they're last activity was only seconds or minutes ago), on the otherhand, if they're offline, then I would want to know when their last activity was...(how many days, minutes, hours ago) the easiest way to keep track is to store a unix timestamp directly in the database (Avoids having to do all the conversions). personally I also use a field called `online` (varchar 1) that can have values 'Y' or 'N', speeds up queries, allows me to get online users without grabbing a timestamp, also allows me to see who's online when I'm accessing the database directly (i.e. through phpMyAdmin, or something)
-
that kind of depends how you have things set up. if you have a downloader.php page, that sends out the headers and grabs the file, forcing it to download, you can simply put a counter there, but this will be triggered every time a user starts a download, and does not necessarily mean they actually finish the downloads (they can cancel mid-way). Same applies for the viewing page, just set up a counter for each songID in your songs mysql table. (i.e. add an INT field and increment) with something like mysql_query("update `songs` set songCounter = songCounter +1 where songID = '$sid'",$conn);
-
Collecting userids and inserting row for them
WebStyles replied to EchoFool's topic in PHP Coding Help
I would do it like this: 1. each status phrase has an id (statusID). Statuses are stored in table1 2. each comment has a time/date and the statusID they refer to, stored in table2 when you show a status, you also retrieve the statusID, then you go into table2 and retrieve all comments that have the same statusID, order them by datedesc,time desc. -
And what exactly is not working? what are the errors you're getting? p.s. you're opening the <body> tag, closing it, and then closing it again at the end of the document...
-
A few comments... line 30 $sql_meta = mysql_query("SELECT * FROM sub_cat WHERE name='$sub_cat'"); is the same as line 40. So you're basically pulling out the same information twice (unnecessarily). select * is almost always a bad idea. How are you connecting to the mysql server? are you using persistent connections? consider opening the connection, retrieving data and then closing it... do you also have connections in head, header, totem and footer? (all the included files)
-
Display last 3 image files uploaded to a folder
WebStyles replied to WOWDesigns's topic in PHP Coding Help
in that case you don't need to read through the folder contents, you can simply store the file names in a $_SESSION variable when the user uploads and you move them to the final destination, then simply present the user with the file names. -
Display last 3 image files uploaded to a folder
WebStyles replied to WOWDesigns's topic in PHP Coding Help
hmmm there seems to be some confusion with that question... do you want to show the last 3 of the files they just uploaded, or the last 3 that were uploaded (no matter when) ? -
check out this page: http://pt.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting about error reporting.
-
You'll need something like mysql_query("select `name`,`album`,`height` from `tableName` where `artistID` = '$id'",$conn);
-
generate 10 hashes? why? if I sent a request with 0ff11fb076d3d5f9300bdd34fee8a92a7ce76716.13165325 26 all you need to do is compare it (using the weekday example) (assume the has is received in a variable called $requestCode) // split the hash: $parts = explode(".",$requestCode); // check if first part corresponds to today's code (weekday) $today = date("l"); if($parts[0] == sha1($today){ // so far so good... check if timeframe is within 5 seconds: if( ($time() - $parts[1]) < 5) { // ok to continue } } you don't generate anything, both sides generate the hashes on the fly before doing the request, and when receiving a request... you could also include the IP address and stuff like that. it's just one method, now you can make it as complicated as you want.
-
your code searches a database and shows a form. If the database has a value, it shows in the form, otherwise the form is blank. when you add a new value, you're doing the same process all over again and adding the new email to the database at the end of the file... that's why it does not show up when you POST a new address. Move the part where you add the new email to the database, to the beginning of the file instead og the end. That way when your code searched the database for existing emails, the one you just inserted will already be there.
-
you're going to have to store the keys somewhere (or at least the key generation logic), if not in a database, probably in a file (not really secure), and you're going to have to give the key to the client machine... What exactly is the purpose, and who/what are you trying to hide this key from? (the more information, the easier it is to find a solution) Not being sure of exactly what you're trying to accomplish, you could do a challenge/response kind of thing, or a different key based on the weekday... imagine the key is something like a sha1 of the weekday, followed by a timestamp (would look something like: 0ff11fb076d3d5f9300bdd34fee8a92a7ce76716.1316532526) where all you need to know on either side is the day of the week (following this logic you can come up with anything you want, if you use a full date, + hour + minute, you never actually have the same key)... then on the other side, when you receive the request, you check that the key is the same as yours and that the timestamp is within a 5 second period or something...
-
you basically need to create a DSN for the access database, then you can most probably just connect directly from php (since you're on a windows box) and use a simple timeout to refresh the page every x seconds, or ajax to do the same without the silly page jump.
-
what do you mean by "two systems"? two local machines, two remote machines, 2 applications on the same machine? I'm guessing two remote machines... why not digital certificates? PGP pairs, etc... (how exactly will they be communicating?)
-
you could do something like this: <?php $priorityList = array("","Normal","Elevated","STAT"); echo '<select name="priority" size="1" value="priority">'; foreach($priorityList as $p){ echo '<option value="'. $p .'"'; if($row['priority'] == $p) echo ' selected'; echo '></option>'; } echo '</select>'; ?>
-
mysql_fetch_array in a while loop not working
WebStyles replied to nasir1123's topic in PHP Coding Help
the probelm isn't exactly the fact that you're sure it will always exist... what if a malicious user tries to access the script directly without that variable? it will make your server throw an error and possible release some information about your database... You should make sure your scripts all work AND are protected from whatever everyone else might try. -
Cool. I just thought it was something worth checking.... let me know what come up.
-
maybe you have firefox set to use a different connection, firewall or proxy ? or maybe you're running some browsers in your normal system and others in a virtual environment like VirtualBox or VMWare...?
-
do you store the queries made on your site? (by the keywords entered you can probably figure out if it's real users or bots.)
-
you could store the IPS in a text file with a time stamp. something like XXX.XXX.XXX.XXX - 123456789 on each line, and check against that. then set a cron job to run every night that will remove all expired lines from the file. or you could set a delay using javascript from the time the search box gets focus till the time it's allowed to be submitted (robots will submit much faster than it takes a user to type in stuff)
-
mysql_num_rows($return); will give you the number of rows that will be returned by whatever SQL query you have in $return. according to the manual here: mysql_num_rows
-
you use javascript to grab the selected name in the first dropdown. you can trigger the javascript function with the element's onchange tag. You can do a select box with onChange="functionName(this.value);" to send the name, then you use ajax to send that name to a php file that will build the second dropdown and send it back to your javascript, Once you grab the AJAX responseText, you use somthing like this to print the combo onto the page: document.getElementById("divName").innerHTML = returnedComboBox;
-
mysql_fetch_array in a while loop not working
WebStyles replied to nasir1123's topic in PHP Coding Help
you're also doing this: $sql .= ' ORDER BY `concertDatum` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments; without first checking if $_GET['NumLow'] exists or not. and again, at the end, this piece of code will throw a warning and fail if $_GET['NumLow'] is not present and where does $eventOmschrijving come from? if($_GET['NumLow'] > $aantalEvenementen) { echo "$eventOmschrijving=Alle concerten zijn reeds geladen."; } -
only last filed is updated every where
WebStyles replied to amaldasm11sterling's topic in PHP Coding Help
all your $_SESSION variables are invalid, I'm surprised that's even doing anything... this: $_SESSION[empcode] should be: // if the array key name is called empcode $_SESSION['empcode'] or // if you're getting the array key name from a variable called $empcode $_SESSION[$empcode] * you need to fix ALL your $_SESSION variables