redbullmarky
Staff Alumni-
Posts
2,863 -
Joined
-
Last visited
Never
Everything posted by redbullmarky
-
[!--quoteo(post=357567:date=Mar 23 2006, 12:39 PM:name=Hardbyte)--][div class=\'quotetop\']QUOTE(Hardbyte @ Mar 23 2006, 12:39 PM) [snapback]357567[/snapback][/div][div class=\'quotemain\'][!--quotec--] Mark, your the ultimate guru! Thank you so much for your quick responces and you resolved it! Thanks again (im sure Ill be back shortly lol) Hardbyte [/quote] lol not a problem, glad it worked. ahh Stoke and Banbury...happy memories. Cheers Mark
-
ok, just put one more line then [code] $stuff_i_want = $_POST['siteid']; $sites = implode(",", $stuff_i_want); [/code] which will string together all your values ready for inserting into your DB Hope that helps Cheers Mark
-
[code] $viewid = $_GET['id']; ... ... $result = mysql_query("UPDATE registered_files SET hits=hits+1 WHERE id = $viewid") or die (mysql_error()); [/code] would be all you need to do to update the counter quickly. i've added: or die(mysql_error()) to let you know if there's some other problem.
-
couple of points. 1) have you put the select listbox inside your form with a submit button? [b]EDIT:[/b] oh - remember to close your tags (in this case, <option>). sometimes you don't HAVE to, but it's very very good practice if you want fluid, cross-browser code: [code] <form name="myform" id="myform" method="post"> <select name="siteid[]" size="10" multiple id="siteid"> <option value="1">1</option> <option value="2">2</option> </select> <input type="submit" name="Submit" value="Submit" /> </form> [/code] 2) NEVER use $_REQUEST if you can help it. use $_GET or $_POST, depending on where you get the info from. try this at the very top of your page. it'll literally dump the contents of your selected values on the screen, for you to see it working: [code] <?php $stuff_i_want = $_POST['siteid']; print_r($stuff_i_want); ?> [/code] remember, only items tht have been selected will pass their value.
-
try SQL: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']select[/span] [color=blue]count[/color](u_id) [color=green]as[/color] usercount [color=green]from[/color] [color=orange]user[/color] [!--sql2--][/div][!--sql3--] or something like: PHP: [code] $result = mysql_query("select u_id from user"); $members = mysql_num_rows($result); [/code]
-
listboxes, if set up correctly, will post their valus as an array. put open/close brackets directly after the 'name' part of your list item [code] <select name="mylist[]" size="10" multiple id="mylist"> ... options here ... </select> [/code] when you submit the form, $_POST['mylist'] or $_GET['mylist'] (whichever form method you use) will be arrays, with all the values you selected.
-
Useing An Image As A Link Then If statement for that image
redbullmarky replied to skatermike21988's topic in PHP Coding Help
[!--quoteo(post=357533:date=Mar 23 2006, 10:00 AM:name=Skater Mike)--][div class=\'quotetop\']QUOTE(Skater Mike @ Mar 23 2006, 10:00 AM) [snapback]357533[/snapback][/div][div class=\'quotemain\'][!--quotec--] Could You Give Me An Example Code For That??? [/quote] without knowing exactly how you have things set up, it'd be awkward to do the code for you. but for example: [code] <?php if (isset($_GET['foo'])) { echo 'foo is '.$_GET['foo']; } ?> <a href="<?php echo $_SERVER['PHP_SELF'];?>?foo=bar"<img src="myimage.jpg" /></a> [/code] if you clicked the image, it would reload the current page with ?foo=bar in your URL, which you can then get at with $_GET['foo'] as for javascript, that's a different story and one for the javascript forum, but basically you load all the info you need into a table with the CSS style 'display:none', and when the image is clicked (using onClick) it sets the CSS style of the table so that it shows. -
[!--quoteo(post=357532:date=Mar 23 2006, 09:50 AM:name=thetwai)--][div class=\'quotetop\']QUOTE(thetwai @ Mar 23 2006, 09:50 AM) [snapback]357532[/snapback][/div][div class=\'quotemain\'][!--quotec--] I need to get how many session my server currently has? Is there anyway to get the session count? The problem is I want to know who is online on my site. Please Help me TW [/quote] you COULD count the number of files in the session folder on your server, but you wouldnt really be able to determine who of your registered users is online. to do that, you'd need to create a custom session handler. the code could drag on, but this will give you an idea how it works. 1, each page in your site should 'include' a sessions.php (or whatever you decide to call it) script, with the session handling functions. 2, the sessions.php file will update the 'last active' field in your mysql sessions table with the current time. also, it will automatically delete records from the table who's last activity was over a certain time. if the users session does not exist in the table, create it. 3, on your 'who is online' page, all you need to do is read and display all of the records from your sessions table.
-
[!--quoteo(post=357528:date=Mar 23 2006, 09:23 AM:name=rach)--][div class=\'quotetop\']QUOTE(rach @ Mar 23 2006, 09:23 AM) [snapback]357528[/snapback][/div][div class=\'quotemain\'][!--quotec--] anyway we can do that using sql command ? [/quote] you'd have to check, but something like: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] REPLACE(Telnum, [color=red]'[span style=\'color:orange\']-[/color]'[/span], '') [color=green]as[/color] NiceTelnum [color=green]FROM[/color] [color=orange]mytable[/color] [!--sql2--][/div][!--sql3--] may work for you
-
for the first 4 things ,you could do it with one check, then check the other bits seperately. make a function: [code] function check_ni($ni) { $ni = strtoupper($ni); $not_first_two = array('D','F','I','Q','U','V'); $is_ni = preg_match('/^[A-Z]{2}[0-9]{6}[\ A-D]{1}$/', $ni); if ($is_ni) { if (in_array($ni[0], $not_first_two) || in_array($ni[1], $not_first_two)) { return false; } else { return true; } } else return false; } [/code] only think it doesn't do is check the pairs for invalid pairings, but it should set you on your way. cheers [b]EDIT:[/b] Just had a playaround with it and alot of it can be taken out: [code] function check_ni($ni) { $ni = strtoupper($ni); $is_ni = preg_match('/^[A-CEG-HJ-PR-TW-Z]{2}[0-9]{6}[\ A-D]{1}$/', $ni); if ($is_ni) { return true; } else return false; } [/code] on the Preg_match line, please note the space in the [\ A-D] part
-
[!--quoteo(post=357525:date=Mar 23 2006, 09:13 AM:name=rach)--][div class=\'quotetop\']QUOTE(rach @ Mar 23 2006, 09:13 AM) [snapback]357525[/snapback][/div][div class=\'quotemain\'][!--quotec--] i have a list of phone number key in with 012-34567897 i want to split the '-' so that the phone number become 01234567897. anyone knows how to do that ? thanks [/quote] i guess this would do you: [code] $num = str_replace('-', '', $num); [/code] hope that helps
-
without going as far as the time warning, i have a function on most of my sites that allows me to take it offline. in every page in my site, i include a 'configuration.php' file, which along with making sure certain settings are set up, etc, also checks my database to see if i have requested the site to go offline. just a simple SELECT from the database. if the site is offline, i just use: [code] if ($offline) { header("Location: bebacklater.php"); exit; } [/code] to do the redirect. if you wanted to do a time warning then: (assiming that $offlinetime is the timestamp you have set to go offline, read from the database. ie 15 minutes into the future) [code] if ($offline) { if (time()>=$offlinetime) { header("Location: bebacklater.php"); exit; } else { // how many minutes before shutdown? $timetoshutdown = ($offlinetime- time()) / 60; $timetoshutdown = round($timetoshutdown); $system_message = "The site will go offline in approximately ".$timetoshutdown." minutes"; } } [/code] you can then use the variable $system_message to display a message to users on pages they visit during a timeout period. so to kick off the above, then in your admin panel all you need is a mysql_query that sets an 'offline' field to true, and a field 'offlinetime' to: time()+(60*15). hope that makes sense.
-
obsidian, apologies if this is covering what you were getting at. in my opinion, $_GET, $_POST and $_COOKIE (GPC) are the three to really be super-paranoid about if you want a secure site, as they're the 3 php superglobals that primarily deal with input from the user. if you're not doing some sort of processing, no matter how simple the script is, on these three, then you're asking for trouble as either can be exploited with certain code to either make your script act erratically or reveal/do things that you don't want. whilst 'SQL Injection' is mainly aimed at people dealing with mysql databases, the principles involved and the methods to cut out injection relate to scripting whether you use a database or not. if your system is kinda like a templating system, then use an array/mysql/flatfile system to store and retrieve the information you need rather than allowing a user to get 'straight to the heart' of your code'. so if you had a templating system, you might have something like: [code] $module = $_GET['action']; $all_actions = array('thisone'=>'thisone.php', 'thatone'=>'thatone.php', 'theother'=>'theother.php'); if (isset($all_actions[$module])) { include($all_actions[$module]); } else { echo 'get out of here!!!!!!'; exit; } [/code] obviously there is more to consider, like checking for invalid characters in the URL parameter, but what the above does is puts a barrier or two in between the user and the script. from my old college teacher: a bouncer at the door of a night club will stop most under-age drinkers getting in, but there's always one that can get through. put an extra one or two on the door, who all ask for age identification, and things get much harder for them. it's not much different in web security. stop everything that comes through, check it thoroughly, etc, and maybe your site won't get shut down like a club that lets under-age drinkers in.
-
nothing in computing is limitless, however i have (so far) found no reason to worry about the size of session data. storing the odd character here, number there, etc,will not really amount to enough to cause major problems. when a session is started, a file is created on the server which holds your info. when your session expires (or you close your browser) the session file ceases to exist. if i'm honest, i'm not sure if there is any 'set' limit on session size. if their isn't, then the size would be determined by how much space is actually used by all of the session files on the server. if youre that worried about how much you store, then simply look through your code and see if you are storing info that NEEDS to be stored (ie, preloading an entire database wouldnt be advisable). user info, users settings, etc are fine. but entire lists of teams and team data would probably be better on your server if they were read from the database as required, rather than stored.
-
[!--quoteo(post=357246:date=Mar 22 2006, 11:19 AM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Mar 22 2006, 11:19 AM) [snapback]357246[/snapback][/div][div class=\'quotemain\'][!--quotec--] your_page.php?var=something $variable = $_GET['var']; $variable will now be "something" You can then use <?=$variable?> to insert it into your html object or whatever. [/quote] yep. just to elaborate on that incase youre not sure, you need to put php into your code: [code] <?php $vid = $_GET['vids']; ?> <object type="application/x-shockwave-flash" width="400" height="220" wmode="transparent data="video/flvplayer.swf?file=<?php echo $vid; ?>" <param name="movie" value="video/flvplayer.swf?file=<?php echo $vid; ?>" /> <param name="wmode" value="transparent" /> </object> [/code]
-
[!--quoteo(post=357130:date=Mar 21 2006, 10:54 PM:name=Beamer)--][div class=\'quotetop\']QUOTE(Beamer @ Mar 21 2006, 10:54 PM) [snapback]357130[/snapback][/div][div class=\'quotemain\'][!--quotec--] Sorry, but I mean the top layer is an external image from the server and I want to put that over a colored background. [/quote] the priciples and practices are exactly the same whatever you want to do, if it is in fact the GD you want/need. [code] $color = $_GET['color']; $r = hexdec(substr($color,0,2)); $g = hexdec(substr($color,2,2)); $b = hexdec(substr($color,4,2)); [/code] if it's an element you need to change, depending on the $_GET value of 'color', then just insert it where you would normally do it with CSS. for example: [code] <div style="background-color:#<?php echo $_GET['color']; ?>"> <p>hello world!<p> </div> [/code]
-
[!--quoteo(post=357111:date=Mar 21 2006, 10:11 PM:name=netfrugal)--][div class=\'quotetop\']QUOTE(netfrugal @ Mar 21 2006, 10:11 PM) [snapback]357111[/snapback][/div][div class=\'quotemain\'][!--quotec--] I'm looking to create a bar graph in php that allows me to view when an event is occuring during the day or week. It is similar to what Microsoft Outlook calendar does. Basically, I want to see a horizonal bar from a start time to an end time during a day. Does anyone know of any tutorials that explain this? thanks [/quote] as the blocks are all square, it'd probably be less hassle to actually use DIVs/tables to do this. it'd also use up much less bandwidth to output to the browser than an image.
-
[!--quoteo(post=357100:date=Mar 21 2006, 09:23 PM:name=Beamer)--][div class=\'quotetop\']QUOTE(Beamer @ Mar 21 2006, 09:23 PM) [snapback]357100[/snapback][/div][div class=\'quotemain\'][!--quotec--] [b]EDIT: [/b]I get two errors when trying out: color=ff0000 Warning: imagecolorallocate(): supplied argument is not a valid Image resource in test.php on line 9 Warning: imagecolorallocate(): supplied argument is not a valid Image resource in test.php on line 12 [/quote] did you create the image first? sorry, i didnt include that in my example as i thought you'd already have that bit, but you need to use: [code] $width = 800; $height = 600; $image = imagecreate($width, $height); [/code] before you use imagecolorallocate, etc. (you can also use 'imagecreatetruecolor' in the same way). the script will work with any sort of GD drawing, whether it be an ellipse, rectangle, polygon, line, etc. have a look at the manual (http://php.net/imagecreate) for details on getting things set up and also links to all the other functions you may find useful.
-
on this line: [code] if (mysql_fetch_assoc($rs)==0){ [/code] you're checking if an entire array equals 0. even if there are no rows, it still wont return the number 0. what you need is [code] if (mysql_num_rows($rs) == 0) { [/code]
-
[!--quoteo(post=357050:date=Mar 21 2006, 07:10 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 21 2006, 07:10 PM) [snapback]357050[/snapback][/div][div class=\'quotemain\'][!--quotec--] Check All boxes are usually controlled via Javascript. Ken [/quote] yep, this belongs in the javascript forum, but this is a little function that does what youre after. just use something like: onClick='check(document.form1.myfield)' whereas myfield is the name and id of all of your checkboxes: [code] var checkflag = "false"; function check(field) { if (checkflag == "false") { for (i = 0; i < field.length; i++) { field[i].checked = true; } checkflag = "true"; } else { for (i = 0; i < field.length; i++) { field[i].checked = false; } checkflag = "false"; } } [/code]
-
[!--quoteo(post=357040:date=Mar 21 2006, 06:01 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 21 2006, 06:01 PM) [snapback]357040[/snapback][/div][div class=\'quotemain\'][!--quotec--] I have read your post and thank you for your time cheers. [/quote] not a problem. honestly, i remember some of the stuff they used to teach me at college... as for what type of loop to use, i generally have a few rules of thumb when deciding which one to use: 1) 'for' loops - i use these when i know how many times the loop needs to be executed, and i need to keep tabs on the counter 2) while loops - i use these if i need to test a condition or initialise some data BEFORE executing a loop an unspecified amount of times. for example, when i want to pull out a row from the database and display it, but dont initially necessarily know (or care) how many rows i have. this example pulls EVERY result from a database query: [code] while ($row = mysql_fetch_assoc($db_result)) { echo $row['name'].'<br>'; } [/code] 3) do...while loops - same as 2, but when i want to execute a loop at LEAST once. eg: [code] $row = mysql_fetch_assoc($db_result); do { echo $row['name'].'<br>'; while ($row = mysql_fetch_assoc($db_result)); [/code] hope that'll clear it up. Cheers
-
to be honest, i don't know what youre trying to achieve. if youre actually doing this for a final project, dont. if youre doing it for a school/college project, don't. there are better ways of achieving the same thing. here, you set up a for loop to go from 1 to 24. however, values 11-24 will never get served, cos you break at 10. why? [code] for($john=1; $john<25; $john++){ [/code] why not do this instead? and you wont even need the 'break' line: [code] for($john=1; $john<11; $john++){ [/code] i'm not even sure if 'break' works with while loops. but wrapping the only method of getting to the end of the while loop within a condition (IF) that will never be met is never going to help you. perhaps if you were to explain what youre eventually trying to achieve, we could help better. but the equivalent of your for loop anyway would be: [code] $john=1; while ($john<11) { $john++; } [/code]
-
[!--quoteo(post=357025:date=Mar 21 2006, 05:27 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 21 2006, 05:27 PM) [snapback]357025[/snapback][/div][div class=\'quotemain\'][!--quotec--] what about if john larger then 2 [/quote] i think you're misunderstanding either me or the 'while' function. ask yourself this - how is $john ever going to be greater than 2, if it's only ever incremented when $john is greater than 2 and starts with the value of 1???
-
[!--quoteo(post=357019:date=Mar 21 2006, 05:17 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 21 2006, 05:17 PM) [snapback]357019[/snapback][/div][div class=\'quotemain\'][!--quotec--] Also can someone tell me about script hang sever please thank you. [code] <? //set john to 1 $john=1; //add while johnless then 10 while($john<10) //add if john equal 2 if($john==2){ //add 1 $john++; } echo "<br> loop stoped at ".$john; ?> [/code] [/quote] i just did. you're sending the while loop into an infinite cycle. you set $john to 1, and you only increment it if $john = 2. but as nothin else increments $john, $john will NEVER equal 2, so the while loop will keep going because $john will ALWAYS be less than 10.
-
[!--quoteo(post=357001:date=Mar 21 2006, 04:22 PM:name=unenergizer)--][div class=\'quotetop\']QUOTE(unenergizer @ Mar 21 2006, 04:22 PM) [snapback]357001[/snapback][/div][div class=\'quotemain\'][!--quotec--] redbullmarky, if I was you, suggestion 1 would be my choice. You say that the ftp login information is going to be changed correct? Well, if they chage it, then it should be hard to remember when the first initial install is being made. So, when they are installing the scrypts, have there ftp info a requirement. This would make it easy on you and your clients, and would prevent confusion with later updates. But you should do what you feel is best. Enjoy, and let us know how everything turns out! :) -unenergizer [/quote] go into the offices of your average recruitment consultant and mention the words 'FTP' and 'Installation'. they'll be screaming 'TECH SUPPORT!!!' before you know it. i'm not disregarding your suggestion, as it really may be the best one. but whilst there's a way to do it WITHOUT them having additional installation and passwords to deal with, i'll probably keep plugging away to find the solution. looking at FTP, it would probably be MY easiest option, and as you say it wouldnt even need to be that complex for them. but this has got to be something so braindead-easy for them it's untrue. and i think my client, and countless other future clients, would respect how easy it is just to 'click and play' without getting into problems. thanks though, and yes - unless anyone else has any further thoughts or would care to elaborate on unenergizers comments, i'll post my results when i get it working. cheers Mark