Jump to content

waverider303

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Everything posted by waverider303

  1. Hey Paul! I figured this out just using a foreach loop. I basically.... foreach ($data as $k => $v) { if($data[$k]['episode'] <= $currVideo) { $move = $data[$k]; unset($data[$k]); $data[] = $move; } }
  2. Thanks Paul!, This works the only issue I run into is I have an array that is like the following: Array ( [0] => Array ( [episode] => 1 [season] => 1 [id] => 3 [title] => "episode 1" ) [1] => Array ( [episode] => 2 [season] => 1 [id] => 4 [title] => "episode 2" ) [2] => Array ( [episode] => 3 [season] => 1 [id] => 5 [title] => "episode 3" ) [3] => Array ( [episode] => 5 [season] => 1 [id] => 7 [title] => "episode 5" ) [4] => Array ( [episode] => 6 [season] => 1 [id] => 8 [title] => "episode 6" ) ) And I want to sort it by the episode number.
  3. I am looking for information on how to accomplish this: I want to order an array based on a variable. I have an array that is set like this array(1,2,3,4,5,6). I want to order this array base on a variable that will be in the array. So say my variable $x = 3, I want to order the array starting with the number right after the $x. So the array would look like this now array(4,5,6,1,2,3). Is this even possible? Another example if $x = 6, The array would be array(1,2,3,4,5,6). So basically order the array so that the set variable (in this case $x) will be at the end and the rest will run in order.
  4. <?php $server = $_SERVER["SERVER_NAME"]; $pattern = "(?:[^\.]+\.)?example.com"; echo "Server is: $server <br />"; switch ($server) { case preg_match($pattern, $server): echo "Worked"; break; /*case "example.com": header('Location: /~root_folder'); break; case "www.example.com": header('Location: /~root_folder'); break;*/ } ?> This is what I have and i am getting "UnKnown modifier errors"
  5. What is "/^[^\.]+?\." searching for? What I am using to get the domain is $_SERVER['SERVER_NAME']; so it will look something on these lines depending on what they type into the url: hainymedia.com www.hainymedia.com subdomain.hainymedia.com test.hainymedia.com and I want to do a preg_match() to find *(meaning wildcard) .hainymedia.com or even just hainymedia.com (missing the leading .).
  6. I get this error: Warning: preg_match() [function.preg-match]: Unknown modifier '+' in /volume1/web/index.php on line 15
  7. 1. I am trying to match all subdomains of my .com to get redirected to a single folder 2. The input data will be $_SERVER["SERVER_NAME"]; so (*.hainymedia.com) * being anything. So that if they goto f2hd4sak.hainymedia.com it will watch it. I am using a Switch conditional so if it find *.hainymedia.com it will redirect to the same folder. I tried to use "\b[A-Z0-9._%+-]+.hainymedia.com" but I am very new to regex and I dont know what I am doing.
  8. I have list of names in my database with page links associated with them. I want to echo out all the entries with their links associated. I want to have it echo out in a list with letter headings. So it would look something like this: A John Adams Marc Anderson Don Aslid B Bob Backley Doug Buckland C Martha Conners Joan Cooper Lambda Culvers etc.....
  9. IS there a script that will select a couple sentences and display them with all their HTML tags (open and closed) intact? Example would be a blog's index page. It displays a few sentences and it spits out all the necessary HTML coding so that the code isnt broken?
  10. I want to include them but do not want them to count.
  11. I have a database of of blog posts and I want to display only a handful of characters from the post. I know of substr and all those but is there a way to have it ignore html code. MY content in the database includes <p> and <span> tags. I dont want substr to count those as characters so that it wont cut out some of my code.
  12. I am receiving an error. I believe it is due to the version of php/mysql that I am running. Here is the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('', '', '', '', 'home', '', '../images') ('', '', '', '', 'home', '',' at line 1
  13. Is this possible to do? for($s=0; $s==$file_len; $s++) { // SQL Statements $sql = "INSERT INTO `upload_images` (`id`, `image_name`, `img_size`, `img_medium`, `img_title`, `page_name`, `bio_link`, `img_url`, ) VALUES ('', '$image_name[$s]', '$sizes[$s]', '$mediums[$s]', '$titles[$s]', '$page_name', '$bio_link', '$img_url')"; if(mysql_query($sql)){ echo "hello!"; } }
  14. Here is my table layouts: CREATE TABLE `comments` ( `comment_ID` bigint(20) unsigned NOT NULL auto_increment, `comment_post_ID` bigint(20) unsigned NOT NULL default '0', `comment_author` tinytext NOT NULL, `comment_author_email` varchar(100) NOT NULL default '', `comment_author_IP` varchar(100) NOT NULL default '', `comment_date` datetime NOT NULL default '0000-00-00 00:00:00', `comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00', `comment_content` text NOT NULL, `comment_approved` enum('Yes','No') NOT NULL default 'No', `comment_agent` varchar(255) NOT NULL default '', PRIMARY KEY (`comment_ID`), KEY `comment_approved` (`comment_approved`), KEY `comment_post_ID` (`comment_post_ID`), KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`), KEY `comment_date_gmt` (`comment_date_gmt`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ; CREATE TABLE `banned_comments` ( `id` int(55) NOT NULL auto_increment, `usr_ip` char(15) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  15. Is this syntax correct? <?php $sql = "REPLACE INTO banned_comm SELECT comment_author_IP FROM comments"; ?>
  16. Ok I have a table that is called COMMENTS inside that table I have a bunch of rows (id, post_id, comment_author, comment_author_email, comment_author_IP, comment_date, comment_content) The primary key in that table is ID and auto_increment. Another table is called BANNED_COMM inside that I just have (id, banned_ip) primary key is ID. I want to delete the entries from COMMENTS and then place only the comment_author_IP into the BANNED_COMM. Do I need something in common with the two tables for this to work?
  17. Ok Thanks for this. Do you have the syntax that goes along with REPLACE INTO?
  18. I have a commenting system on my website. I have it so that each comment is approved before it is posted live on the site. I have an admin center that displays all the comments and lets me Approve, Disprove, and Ban any comments. I have it set so if you approve it changes the database so that it will display it live. If I Disprove the comment it will delete it from the database. If I Ban it I want to delete it then insert the users IP into another database so that that user cannot post any more comments (sort of a spam filter). This is what I have so far but it does not work and I believe this syntax is invalid. <?php $sql = "DELETE FROM comm WHERE comment_ID = '$comment_id'"; $sql2 = "INSERT INTO `ban_com` (`id`, `usr_ip`) VALUES ('', '$usr_ip')"; if(mysql_query($sql) && mysql_query($sql2)) { echo "<p>Removed Comment</p>"; } ?>
  19. I want to create an if statement that will check through an array for a specific ip address (kind of a anti spam system). <?php /* *$usr_ip - is the ip address pulled from the form *$banned_ip - is the array of ip address's to search through */ if (in_array($usr_ip, $banned_ip)) { die("Banned User!"); } else { } ?> Shouldnt This work?
  20. Is this something that should be on or off? Is there any effect when the buffer output is on?
  21. The weird thing is that this works on another site of mine. It only fails on another site I am trying to incorporate this script into. Is related to a specific version of PHP?
  22. I get this warning when I am trying to refresh the page to a different one: Warning: Cannot modify header information - headers already sent by (output started at /home/ada/public_html/v2/ada_login/main.php:9) in /home/ada/public_html/v2/ada_login/main.php on line 36 Here is the code: <?php if($session->logged_in){ header("Refresh: 3 url=welcome.php?uid=$session->userid"); echo '<h3>Creating workspace</h3>'; echo '<img src="images/loader.gif" />'; } ?>
  23. Actually one question I have is if i place this: <?php $sql = "SELECT * FROM db_name WHERE db_row = '$variable'"; $res = mysql_query($sql); while($row = mysql_fetch_assoc($res)) { $page_content = $row['page_content']; } ?> inside the connect.php files and include it on my pages. How would I change $variable depending on the page?
  24. Na your right. I guess that would do. I am trying to segway into classes. Any good tutorials on them?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.