-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
<input type="text" name="category" onKeyUp="SelectSubCat()">
-
<?php $date1 = mktime(0,0,0,9,28,1991); $date2 = mktime(0,0,0,2,18,1996); $diff = $date2 - $date1; $day = 86400; echo floor($diff/$day) . " days"; ?>
-
Um, lol, there's a lot easier way of doing it without using Smarty.
<?php function tpl($output){ $find = array("<{CONTENT}>","<{FOOTER}>"); $repl = array(file_get_contents("content.php"), file_get_contents("footer.php")); return str_replace($find, $repl, $output); } ob_start("tpl"); echo "<{CONTENT}>"; echo "<{FOOTER}>"; ob_end_flush(); ?>
-
That won't work.
Why don't you actually test what you've made?
<?php if ($_POST['submit'] == "Submit") { // connect to db $cn1 = mysql_connect('localhost', $dbuser, $dbpass) or die(mysql_error()); mysql_select_db(ratemy_rater, $cn1) or die(mysql_error()); // check to see if "New UserName" exist" $query = "SELECT m_user FROM rate_members WHERE m_user = $NewUser"; // look for New user in DB $ident = mysql_query($query, $cn1) or die(mysql_error($cn1)); $result = mysql_fetch_assoc($ident); if ($result == false) { // the new username is not in use mysql_query("UPDATE m_user SET m_user = ".$NewUser." WHERE m_user = ".$CUser."") or die(mysql_error()); header("Location: http://www.mysite.com/logout.php"); // log user out so they can re-enter with new name exit(); } elseif ($result == true) { die("Username already in use, please select a another name. Link to update-name.php"); } } else { echo "<form method=\"post\">"; echo "Current UserName: <input type=\"text\" name=\"Cuser\" value=\"\"><br>"; echo "New UserName: <input type=\"text\" name=\"NewUser\" value=\"\"><br>"; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">"; } ?>
-
Um, you're best bet it to burn them to a CD, or you can take a look at this http://www.networkmagic.com/product/file-sharing.php
-
on the page with the clicking
<?php $ip = $_SERVER['REMOTE_ADDR']; $sql = "SELECT * FROM `ip_log` WHERE `ip`='".$ip."'"; $res = mysql_query($sql) or die(mysql_error()); $err = false; if(mysql_num_rows($res) == 0){ $sql2 = "INSERT INTO `ip_log` (`ip`,`clicks`) VALUES('".$ip."','1')"; $res2 = mysql_query($sql2) or die(mysql_error()); $err = false; }else { $row = mysql_fetch_assoc($res); if($row['clicks'] >= 5){ $err = true; }else { $sql3 = "UPDATE `ip_log` SET `clicks`=`clicks`+1 WHERE `ip`='".$ip."'"; $res3 = mysql_query($sql3) or die(mysql_error()); $err = false; } } if($err){ echo "You have already clicked this page 5 times!"; }else { // whatever } ?>
then i guess you can set a cron to run every 24 hours to reset em
-
$var = -400; $pos = abs($var);
get the absolute value
-
main_cats sub_cats topics --------- ---------- -------- id ---| id ---| id name +--- mid +--- sid name name
You have your main category being PHP, your sub-category PHP Help and your topic Forum Nav-Bar?
<?php $topic_id = mysql_real_escape_string($_GET['id']); // example $sql = "SELECT * FROM `topics` WHERE `id`='".$topic_id."'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); $sql2 = "SELECT mid,name FROM `sub_cats` WHERE `id`='".$row['sid']."'"; $res2 = mysql_query($sql2) or die(mysql_error()); $row2 = mysql_fetch_assoc($res2); $sql3 = "SELECT name FROM `main_cats` WHERE `id`='".$row2['mid']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); $row3 = mysql_fetch_assoc($res3); echo $row3['name'] . " > " . $row2['name'] . " > " . $row['name']; ?>
I'm sure you can easily put that into one query, I don't deal with joins :x
-
$sql = "SELECT * FROM `table` WHERE `field` LIKE '%".$tag."%'"; $res = mysql_query($sql) or die(mysql_error());
-
I suppose you can use switch as a method of viewing the latest records.
<?php $from = $_GET['from']; function month(){ $m = ((date("m")-1) > 0) ? date("m")-1 : 12; $day = 86400; $to = 31*$day; $t = 30*$day; $ms = array(1 => $to, 2 => 28*$day, 3 => $to, 4 => $t, 5 => $to, 6 => $t, 7 => $to, 8 => $to, 9 => $t, 10 => $to, 11 => $t, 12 => $to); return $ms[$m]; } switch($from){ case 'week': $seconds = 7*86400; break; case 'biweek': $seconds = 14*86400; break; case 'month': $seconds = month(); break; } // your query ?>
-
<?php $referer2 = $_SERVER['HTTP_REFERER']; echo "<a href=\"".$referer2."?link=1\">A LINK</a>"; ?>
-
Yep, just convert the dates to timestamps and sort them.
<?php $date = strtotime(date("M d, y")); $dates[] = strtotime("+3 days", $date); $dates[] = strtotime("+1 week", $date); $dates[] = strtotime("+1 year", $date); $dates[] = strtotime("+1 month", $date); sort($dates); $closest = $dates[0]; $farthest = $dates[3]; echo date("M d, y", $closest); // plus 3 days echo "<br>"; echo date("M d, y", $farthest); // plus 1 year echo "<br><br>"; // now all the dates foreach($dates AS $dated){ echo date("M d, y", $dated) . "<br>"; } ?>
-
You can explode it.
<?php $sql = "SELECT tags FROM `videos` WHERE `id`='5'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); $tags = explode(",", $row['tags']); foreach($tags AS $tag){ echo "<a href=\"search.php?tag=".trim($tag)."\">".$tag."</a> "; } ?>
-
Remove the LIMIT 1
-
No, what he's doing is fine.
-
How are you attempting to make the music play? Flash MP3 Player?
-
For an ideal advanced search system, you can easily start by defining what table you're looking in.
<?php $by = $_POST['by']; $type = $_POST['type']; $query = $_POST['query']; // of course you should protect the data above $sql = "SELECT * FROM `users`"; switch($type){ case 'exact': $addon = "='".$query."'"; break; case 'cont': $addon = " LIKE '%".$query."%'"; break; default: $addon = "='".$query."'"; } switch($by){ case 'username': $sql .= " WHERE `username`" . $addon; break; case 'email': $sql .= " WHERE `email`" . $addon; break; case 'name': $sql .= " WHERE `name`" . $addon; break; default: $sql .= " WHERE `username`" . $addon; } $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "Your search returned no results!"; }else { while($row = mysql_fetch_assoc($res)){ echo $row['username'] . " // " . $row['email'] . " // " . $row['name'] . "<br>\n"; } } ?>
-
$var is not defined.
if($soc >= 50){
-
There's also no use of defining the variables like that when you can simply put them in the single quotes at real numbers/strings.
-
-
<?php if($_SESSION['username'] || $_COOKIE['user']) { logged(); }else { //show code } ?>
if it's set show the logged in message, if either are, show the login form thing
-
That's not how you would change a cookie... that's how you call a cookie. To change or create a new cookie you need to use setcookie, cookies dont work like sessions.
-
<?php $data = $_POST['main']; $name = $_POST['name']; if(!$data || !$name){ echo "You need data and/or a name!"; }else { $file = "/games/" . $name . ".php"; if(file_exists($file)){ echo "The file <b>".$file."</b> already exists!\n"; }else { $f = fopen($file, "w+"); fwrite($f, $data); fclose($f); echo "The game file has been created!\n"; } } ?>
-
You need to make the message read HTML using the mail headers.
Sessions help.
in PHP Coding Help
Posted
Why register a session variable and not use it when you need to.