-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
assuming you select the language once for each session, you can use a $_SESSION variable to hold it: session_start(); $_SESSION['lang'] = 'en'; require_once('kontakt-obrada_'.$_SESSION['lang'].'.php'); will load: kontakt-obrada_en.php; hope this helps
-
try something like: (assuming you want to add up each players scores ??) "SELECT `username`,sum(`score`) as total FROM `highscores_bubblepop` GROUP BY `username` ORDER BY SUM(`score`) DESC LIMIT 0 , 50"
-
you're still going to have the same problem. Imagine you add a comment for id 89 and store it nicely in a database (with or without other ids)... then 3 months later you happen to add another comment for the same id (89). how will you know which comment refers to which months? Trust me, it's no extra trouble for you to store the month/year and it might be very useful later. Regarding your sql question about storing 3 servicerIds's, it depends. if you will always have exactly 3 ids, then you just create those fields in the database: `id1`,`id2`,`id3`. if there are going to be situations when you have more and don't know how many they will be, just create a text field in the database called `ids` and dump them all in there separated by commas or something.
-
same thing, use COUNT(*) combined with `date` BETWEEN '$starDate' AND '$endDate'
-
well, since the comment (from what I understand) refers to a full month, you will also need to store what month/year is refers to, otherwise you'll just have a series of comments with a date and an id, that's ok for linking it back to the correct id, but not the correct month (image the comment is inserted in the first of july, but actually refers to the month of june.
-
Special characters work only on some servers only. (flat file cms)
WebStyles replied to r0b's topic in PHP Coding Help
it's quite a lot of code, sod I can't really re-create your situation right now because I'm at work, but I can suggest a few more things: 1. check if txt files were also created with UTF-8 2. you can use file_put_contents() to save to the files instead of fopen/fwrite and fclose. 3. maybe track the exact situation where the error occurs (i.e. operating system + browser version) to see if there's a pattern and narrow down the problem. -
well, if you read the text file into a variable (get_file_contents('filename.txt') is the prefered method.) you can then split it into lines. then if you split each line into words, you just need to grab the first word and use a variable to store that so you can compare if it repeats or not. something like this: $file = file_get_contents('filename.txt'); $lines = explode("\n",$file); // assuming \n is the used linebreak foreach($lines as $line){ $words = explode(" ",$line); $firstWord = $words[0]; // do some processing and store $firstWord in a variable like: $lastWordUsed. } then all you need to do is check if $firstWord is equal or not to $lastWordUsed. Hope this helps
-
it really depends on your table structure. You can just create a table for the comments like I said before, and use a field to track whick month you're referring to, something like: id, month, year, comment. That way you don't need to store all the information, because you can always fetch it from the original database if needed, since you'll have the year, month and id to reference it.
-
what I normally do is have a javascript/ajax with a little timeout (say every 60 seconds so it doesn't use too much resources) that checks if the users are still logged in and saves the time of the last update. whenever it runs, all the users that have not updates for over 65 seconds are considered logged out, the I update the sessions accordingly.
-
you can grab the 3 months with a simple BETWEEN statement SELECT * FROM `table_name` WHERE `date` BETWEEN '$start_date' AND `$end_date`
-
URL Case Sensitive Issue Casing Ranking Problems
WebStyles replied to zehrila's topic in PHP Coding Help
from what I gather, you have a database with words like "Green", "Blue", "Whatever" that you use to list stuff and then build urls, is that correct? in that case you should either convert all to lowercase in database and user ucwords() before displaying them (so they look nice for the visitor) and the raw output to build the links, or the inverse: don't change anything, present the raw output to the visitor, but build the urls with strtolower() to ensure they're all lowercase. (I may be misinterpreting you problem) -
To get the last 3 records from Services all you need is something like this: $sql="SELECT * FROM `Services` WHERE `Staffname`='$id' ORDER BY `ServiceDate` DESC limit 3" ; instead of $sql="SELECT * FROM Services WHERE Staffname='$id' AND ServiceDate='$lastmonth' OR Staffname='$id' AND ServiceDate='$lastmonth1' OR Staffname='$id' AND ServiceDate='$lastmonth2' ORDER BY ServiceDate" ; From what I understand, all you want to do is add a comment on each record, 3 at a time, and instead of saving into same database, you want to save it all in a new table. correct? Why would you create this duplication? Why not create a table called comments, just add the comments and the reference to witch record the comment belongs to? Unless you're duplicating everything with the purpose of then deleting the first table, but in that case you could also just add the comment field to the first table an populate that.
-
URL Case Sensitive Issue Casing Ranking Problems
WebStyles replied to zehrila's topic in PHP Coding Help
strtolower() will convert a string to lower case. -
please post the code you have so far.
-
I'm assuming InternetProtocal.txt has a list of valid ip's and that they are seperated by a semicolon ( so, first you need to read that file and put all the addresses in an array $file =file_get_contents('InternetProtocal.txt'); $ips_on_file = explode(";",$file); next, grab the clients IP address and check to see if it exists in you list: $client_ip = $_SERVER['REMOTE_ADDR']; if(in_array($client_ip,$ips_on_file)){ // OK TO PROCEED }else{ // NO ACCESS } Hope this helps
-
I'm assuming you know how to connect to a database and use a simple mysql_query. So try something like this (assuming you have a function called conn() that handles the database connection and that there is a field in the database called username): $username = 'Johnny Bravo'; $conn = conn('database_name'); $q= mysql_query("select `views`,`favourites`,`subscribers` from `users` where `username`= '$username'",$conn); $r = mysql_fetch_assoc($); @mysql_close($conn); if(!empty($r)){ $total = $r['views'] + $r['favourites'] + $r['subscribers']; echo $total; }else{ echo 'username not found in database'; }
-
you can store a list of still images for each video and cycle through them on roll over.
-
this line: if (!mysql_query($sql, $con)) is failing because there is no $sql variable defined. there are also some other strange things with the order of your lines, try creating a little function to handle all sql conections, where you pass the database name into, something like this: (it keeps things nice and tidy and allows you to re-use the code) function conn($db_name){ $db_host = "localhost"; $db_user = "developer"; $db_pass = "javalab"; $c = mysql_connect($db_host, $db_user, $db_pass) or die('Cannot connect to sql server '.mysql_error()); mysql_select_db($db_name,$c)or die('Cannot select database '.mysql_error()); return $c; } then what you do is something like this: $con = conn('database_name'); $result = mysql_query("delete from `travels` where `travel_id`='$tID' limit 1",$con); @mysql_close($conn); if(!$result){ echo 'error'; }else{ echo 'success'; }
-
Just uploaded that script to my server and it worked fine. so I uploaded to my godaddy server and also worked fine (godaddy takes 10 times longer to deliver emails though)
-
check the permissions of your .txt file, maybe that's where it's failing. hope this helps.
-
Romku - Collaborative Website that references Software
WebStyles replied to pmorel's topic in Website Critique
yes, I mean the filters on the top left side. Once i searched for photoshop, then I clicked OS X in the filter box, and every time I would select another one, they would change their order. Good luck with the project. -
check out the $_SERVER vars page on php.net, and you'll see all the options there. some options will grab the page name, some will grab the domain, some will grab the variables. hope that helps.
-
when your 30+ domains are redirected to the main domain, does the domain name change in the browser? (what I'm getting at here is, if the domain name does not change, then you just need to grab that and redirect to a folder or do something with it, if it does change then you grab the referrer and do the same.) Anyway you look at it, you answered the question yourself, the answer is in the $_SERVER variable and it's a very simple process. Hope this helps
-
what PFMaBiSmAd is saying is, instead of this: $message .= "<br>Name: $firstname $lastname \r\n"; try this: $message .= "<br>Name: ".$_POST['firstname']." ".$_POST['lastname']." \r\n"; or, before inserting into database and echoing, grab the POST variables into local variables: $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; hope that helps
-
Special characters work only on some servers only. (flat file cms)
WebStyles replied to r0b's topic in PHP Coding Help
sounds like an encoding issue. where's your <head> section. are you defining utf-8 on all pages?