jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
Welp, I don't know wordpress, but I would suggest a little de-bugging. $custom = get_post_meta($post->ID); echo '<pre>' . print_r($custom,true) . '</pre>'; $item_link = $custom["item_link"][0];
-
if ( {$_SERVER['REMOTE_ADDR']}.== "") $ip = "no ip"; To: if ( empty($_SERVER['REMOTE_ADDR']) ) $ip = "no ip"; else $ip = getHostByAddr( {$_SERVER['REMOTE_ADDR']}. ); To: else $ip = getHostByAddr( $_SERVER['REMOTE_ADDR'] ); if ($_POST['action'] != ""): To: if ( !empty($_POST['action']) ):
-
PHP generated gallery - Implementing Lightbox?
jcbones replied to mat3000000's topic in PHP Coding Help
According to Lightbox's tutorial, you need to point the `rel` attribute at lightbox. <a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a> -
Run this: <?php function dirContents($dir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(in_array($file,array('.','..'))) { continue; } if(is_dir($dir.'/'.$file)) { $contents[$dir.'/'.$file] = dirContents($dir.'/'.$file); } else { $contents[] = $dir . '/' . $file; } } closedir($dh); } } return $contents; } function processArray($array) { if(is_array($array)) { echo '<ol>'; foreach($array as $key => $value) { if(is_int($key)) { echo '<li><a href="'.$value.'">'.str_replace('/','',strstr(strrchr($value,'/'),'.',true)).'</a></li>'; } else { echo '<li><span style="font-weight:bold">' . $key . '</span>'; processArray($value); echo '</li>'; } } echo '</ol>'; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" /> <meta name="author" content="FilmZilla"> <meta name="publisher" content="FilmZilla"> <meta name="copyright" content="FilmZilla"> <style type="text/css"> @import url(styles.css); </style> <title>FilmZilla</title> </head> <body> <div id="header">FilmZilla</div> <div id="bar_nav"> <ul> <a href="#">Home</a> <a href="Donate.html">Donate</a> </ul> </div> <div id="content_left"> <h1>Newest Films</h1> Planet 51 <BR> Scream 4 <BR> Xmen First Class </div> <!-- this is where the film links are ################################################## --> <div id="content"><h1>Films</h1> <?php $dir = 'films'; $files = dirContents($dir); processArray($files); ?> <!--this is where the film links end ################################################## --> </div> <div id="bar_bottom2"><marquee>Films are all DVDRIP. Please donate. Do not take credit for these movies!</marquee></div> <div id="bar_bottom">© 2011 | Copyright © FileZilla</a></div> <!--[if IE]></div><![endif]--> <div style="text-align: center; font-size: 0.75em;">Copyright© FilmZilla</a>.</div></body> <link rel="shortcut icon" href="icon.ico"> <link rel="icon" type="image/gif" href="icon.png"> </html> Don't change anything, but put this script in the directory that HOLDS the 'films' folder! NOT in the 'films' folder.
-
Ummm, I wrote the script, and I ALSO gave you the cure. If you read, it will come.
-
Yep, that happens when you try to feed it a relative file path, with a slash BEFORE the first directory. $dir '/films/'; //incorrect. $dir './films'; //correct. $dir 'films'; //correct. $dir 'films/'; //incorrect.
-
http://www.consumerfraudreporting.org/MLMscams.htm http://en.wikipedia.org/wiki/Pyramid_scheme I think in order for it to be legal, you can only pay a referral fee to the person referring. If the person is receiving a legit 'subscription', to a real product, you could go back several layers deep. In other words, paying $8 a month for a subscription to news.google.com is NOT going to make it legal.
-
Mysql Question: Loading database info from more than one table.
jcbones replied to Hall of Famer's topic in PHP Coding Help
Well, you could update them all at once, inside of MySQL. If you are processing the passwords in PHP, then you would have to run loops. -
In the above script I gave you, rename the $dir variable to the folder you want. ie. films. Sorry, I left it in test mode. $dir = 'path/to/folder'; //without trailing slash. The link will be the same name as the avi filename, without the extension, and will link directly to that file. Try it out, if you have questions on how it works, or the formatting, post the specific question.
-
Mysql Question: Loading database info from more than one table.
jcbones replied to Hall of Famer's topic in PHP Coding Help
Yes, it is possible, and one of the key features of mysql. MySQL is a relational database, so pulling a query from tables that 'relate' to each other is a feature. JOIN is the syntax you are looking for. -
I found an old function in my library that was easily retrofitted for this application. I don't really like echo'ing out of functions, but it was the easiest way to solve the unknown depths the resulting multi-dem array. <?php function dirContents($dir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(in_array($file,array('.','..'))) { continue; } if(is_dir($dir.'/'.$file)) { $contents[$dir.'/'.$file] = dirContents($dir.'/'.$file); } else { $contents[] = $dir . '/' . $file; } } closedir($dh); } } return $contents; } function processArray($array) { if(is_array($array)) { echo '<ol>'; foreach($array as $key => $value) { if(is_int($key)) { echo '<li><a href="'.$value.'">'.str_replace('/','',strstr(strrchr($value,'/'),'.',true)).'</a></li>'; } else { echo '<li><span style="font-weight:bold">' . $key . '</span>'; processArray($value); echo '</li>'; } } echo '</ol>'; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" /> <meta name="author" content="FilmZilla"> <meta name="publisher" content="FilmZilla"> <meta name="copyright" content="FilmZilla"> <style type="text/css"> @import url(styles.css); </style> <title>FilmZilla</title> </head> <body> <div id="header">FilmZilla</div> <div id="bar_nav"> <ul> <a href="#">Home</a> <a href="Donate.html">Donate</a> </ul> </div> <div id="content_left"> <h1>Newest Films</h1> Planet 51 <BR> Scream 4 <BR> Xmen First Class </div> <!-- this is where the film links are ################################################## --> <div id="content"><h1>Films</h1> <?php $dir = 'test'; $files = dirContents($dir); processArray($files); ?> <!--this is where the film links end ################################################## --> </div> <div id="bar_bottom2"><marquee>Films are all DVDRIP. Please donate. Do not take credit for these movies!</marquee></div> <div id="bar_bottom">© 2011 | Copyright © FileZilla</a></div> <!--[if IE]></div><![endif]--> <div style="text-align: center; font-size: 0.75em;">Copyright© FilmZilla</a>.</div></body> <link rel="shortcut icon" href="icon.ico"> <link rel="icon" type="image/gif" href="icon.png"> </html>
-
while loop mysql_fetch_array single output
jcbones replied to undertaker333's topic in PHP Coding Help
There is no way to help you with the code provided. We would need a database dump to see what is going on. -
When in doubt, copy/paste the query string into phpMyAdmin, or equal database software. You could also type it into the mysql console.
-
So, set a Session variable that keeps track of the user. Top of each page. <?php session_start(); $_SESSION['page'] = 'this_page.php'; ?> Login. <?php session_start(); //do login. if($login == true) { header('Location: ' . WEB_ROOT . '/' . $_SESSION['page']); } Or, something to that affect.
-
GAHHHH!!!! Gonna have to quit posting without sleep.
-
PHP should be coded: 1. Processing 2. Displaying So, keep your processing separate from you display, and you will not run into these problems. All processing should happen before you include that 'header' file.
-
Yes, but PLEASE remove the error suppression. (just a pet peeve of mine).
-
Is the amount column a float? $sql="SELECT SUM(`amount`) AS total FROM tickets WHERE `round` = '$round' AND `confirmed` = 'yes' ORDER BY id ASC"; $result=mysql_query($sql); $row=mysql_fetch_array($result); while($row = mysql_fetch_array( $result )) { echo $row['total']; }
-
<?php $string = "The quick red fox\n jumped over the brown\n lazy dog."; function first_of_string($str) { //php magic return strstr($first_of_string, "\n",true); // -> php 5.3.0 } echo first_of_string($string); //would produce "The quick red fox" ?>
-
May I suggest a series of video's that you need to watch Make sure you watch all nine of them. You should then be able to normalize a relational database. This will help you in your current and future projects.
-
Here is a table structure that I used in the past. CREATE TABLE IF NOT EXISTS `instant_message` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date_of_event` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `recipent` int(11) NOT NULL, `sender` int(11) NOT NULL, `message` text NOT NULL, `replied` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `resolved` int(1) NOT NULL, `sender_delete` int(1) NOT NULL DEFAULT '0', `recipent_delete` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
-
<?php error_reporting(E_ALL); ini_set('display_errors',1); if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ //eregi is depreciated, use preg_match functions. $error.="Invalid email address entered"; $errors=1; } if($errors == 1) { echo $error; } //php complaining about an output here causing the header to fail, don't know why as there should be no output unless $errors == 1, wrapped if statement in brackets to see if it stops it. else{ $values = array ('name','email','message'); $required = array('name','email','message'); $your_email = "myaddress@gmail.com"; $email_subject = "New Message: ".$_POST['subject']; //php complains because there is NO subject to get the data from, check your form and make sure spelling is right. $email_content = "new message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(mail($your_email,$email_subject,$email_content) !== false) { header('Status: 200'); //for Chrome. header("Location: http://www.temporary.com"); } else { echo 'ERROR!'; } } ?>
-
Try Form <body><form action="contact.php" method="post" name="input" target=_blank> <h2><span class="style14">Contact Inquiry Form </span></h2> <p> </p> <p> <span class="style24 style2">Customer Name</span> <br> <input name="firstname" type="text" size="50"> First Name<br> <br> <input name="lastname" type="text" size="50"> Last Name</br> </p> <p> <span class="style24 style2">Email</span><br> <input name="email" type="text" size="50"> </br> </p> <p> <span class="style24 style2">Phone</span> <br> <input name="phone" type="text" size="50"> </br> </p> <p> <span class="style24 style2">Company Website (if applicable)</span> <br> <input name="company" type="text" size="50"> </br> </p> <p> <span class="style24 style2">Please describe your interest in Statistics & Research Consulting</span> <br> <textarea name="message" cols="50" rows="10"></textarea> </br></p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> contact <?php $to = 'inquiry@srcfresno.com'; $subject = 'Contact Inquiry form'; if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); } $fields = array( 'firstname' => 'First Name', 'lastname' => 'Last Name', 'email' => 'Email', 'phone' => 'Phone', 'company' => 'Company Website (if applicable)', 'message' => 'Please describe your interest in Statistics & Research Consulting' ); $body = "We have received the following information:\n\n"; foreach($fields as $a => $b) { if(array_key_exists($a,$_POST)) { $body .= sprintf("%s: %s\n",$b,$_POST[$a]); } } $send = mail($to, $subject, $body); if($send) {print "Thank you for contacting us. We have received your information and a SRC Consultant will respond shortly."; } else {print "We encountered an error sending your mail, please notify webmaster@srcfresno.com"; } ?> Let us know how it goes.
-
We really need to see the form! I'm not sure you are asking for the correct inputs.