Jump to content

Search the Community

Showing results for tags 'id'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 16 results

  1. Hi, I have a problem. I am doing one little job with php and html. In html i have textbox in which person id must be entered (11 numbers) I need to do with php that when all 11 numbers are entered, date of birth and gender need to be shown, For example: if id is : 39310121111 first number stands for mele/female (if 3 mele if 4 female) all next numbers are date of birth 1993 10 12 (last 4 numbers doesnt have meaning) Basicly question is. how to make syntax that entered id will be shown as gender and date of birth ? can't think of any ideas. new at php.
  2. Say I have 2 tables. Table 1: Type(type_id, type_name) Table 2: Records(record_id, record_name, record_type) Under the "record_type" column, is it better to use type_id(eg. 10) or type_name(eg. Clothing & Watches)? If the answer is use the name, is it better to use the original name(Clothing & Watches) or a slug name(clothing-watches)?
  3. hi, can anyone tell me anything wrong with my coding as it keeps mentioned undefined index,id tambahitem.php
  4. I want to be able to grab any new images uploaded and display them right away on the front page, at the moment I can grab the id of each but that won't update the gallery. Once 4 images are uploaded, the next one to be uploaded pushes the last out of the gallery. At the moment, I only have 2 images on the db, but I want it ready to be used by a community <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> Upload:<br><br> <input type="file" name="image"><br><br> <input type="submit" name="submit" value="Upload"> </form> <?php if(isset($_POST['submit'])) { mysql_connect("localhost","____","____"); mysql_select_db("moduni_images"); $imageName = mysql_real_escape_string($_FILES["image"]["name"]); $imageData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"])); $imageType = mysql_real_escape_string($_FILES["image"]["type"]); if(substr($imageType,0,5) == "image") { mysql_query("INSERT INTO `images` VALUES('','$imageName','$imageData')"); echo "Image uploaded!"; } else { echo '<br>O<font color="#8B0000">nly images are allowed!</font>'; } } ?> <?php mysql_connect("localhost","____","____"); mysql_select_db("moduni_images"); if(isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $query = mysql_query("SELECT * FROM `images` WHERE `id`='$id'"); while($row = mysql_fetch_assoc($query)) { $imageData = $row["image"]; } header("content-type: image/jpeg"); echo $imageData; } else { echo "Error!"; } ?> <div id="user-gallery"> <h2>Gallery</h2> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> </div>
  5. Hello PHP freaks, my codes dont allow me to log-in to Student Home with unique id. It says "Invalid Login or Password" this is my form <tr bgcolor="#E1E1E1" class="stylesmall"> <td width="35%" align="left" class="style7 style1">Learner Id : </td> <td width="65%" align="left"><input name="learner_id" type="text" id="learner_id" action="Student_Home.php" method="post"></td> </tr> <tr bgcolor="#E1E1E1" class="stylesmall"> <td align="left" class="style7 style1">Password:</td> <td align="left"><input name="student_password" type="password" id="student_password">< /td> and this is my handler. <?php session_start(); include 'Connect.php'; $flag = ""; $learner_id = $_POST['learner_id']; $student_id = $_POST['student_id']; $student_password = $_POST['student_password']; $query = "select last_login_date from student_information where student_id='$student_id' and student_password='$student_password'"; $result = mysql_query($query,$link_id); if(mysql_error() != null){ die(mysql_error()); } if($date = mysql_fetch_array($result)) { $lastdate = $date['last_login_date']; $date2 = date("d-m-Y h:i A",strtotime($lastdate)); $_SESSION["student_id"] = $_POST["student_id"]; $_SESSION["lastlogin"] =$date2; $_SESSION["type"] = "Student"; mysql_query("UPDATE student_information SET last_login_date=now() where student_id='$student_id'",$link_id); if(mysql_error() != null){ die(mysql_error()); } header("location: Student_Home.php?id={$student_id}"); die(); } else { $flag = "invalid"; header("location:Student_login.php?flag=$flag"); die(); } ?> PLease help me PHP friends to correct my codes.
  6. Hey, I'm really new to PHP and having some difficulties with $_SESSION and getting userid from the database. I've managed to put content to my database and also a login script. Though, adding sessions has been a pain. Here's what I got so far: $sql = "SELECT username, password FROM users WHERE username = '$username' and password = '$pas'"; $query_login = $db->prepare($sql); $query_login->execute(array('userid' => $userid, 'username' => $username, 'password' => $pas)); $result = $query_login->rowcount(); if ($result>0) { session_start(); $_SESSION['username'] = $username; $_SESSION['logged'] = 1; $_SESSION['userid'] = $result['userid']; header('Location: ../user/user.php'); }
  7. hi, im trying to create a website and only now started thinking about the security part(noob mistake). say for example i have home.php page and an index.php page. index.php is where users would sign up/log in. the login and sign up processes are all done but i was thinking of creating a unique id of some sort for when the user logs in. or something like this site (forum.phpfreaks) when we sign in, you are signed but the url stays the same = forums.phpfreaks.com. like if we were signed out we will be permanantly signed out and typing in forums.phpfreaks.com would just land us at the main page where we need to sign in. right now ,my home.php can be accessed with or without logging in even with sessions. hope im making sense, thanks in advanced! **haha that rhymed. i tried adding: <?php echo $_SERVER[php_SELF] . '?name=' . $userData['name'];?> in the index.php: <?php ob_start(); session_start(); if(isset($_POST['login'])) { $email = $_POST['email']; $password = $_POST['pass']; require "connection.php"; $emails = mysqli_real_escape_string($con, $email); $query = "SELECT id, name, email, password, salt FROM users WHERE email = '$emails';"; $result = mysqli_query($con, $query); if(mysqli_num_rows($result) == 0) // User not found. So, redirect to login_form again. { echo "<script>alert(\"User does not exist!\")</script>"; } $userData = mysqli_fetch_array($result, MYSQLI_ASSOC); $hash = hash('sha256', $userData['salt'] . hash('sha256', $password) ); if($hash != $userData['password']) { echo "<script>alert(\"Incorrect Password!\")</script>"; }else{ session_regenerate_id(); $_SESSION['sess_user_id'] = $userData['id']; $_SESSION['sess_name'] = $userData['name']; session_write_close(); header('Location: home.php?user='); } } ob_flush(); ?> <!DOCTYPE html> <form name="login" method="post" action="<?php echo $_SERVER[PHP_SELF] . '?name=' . $userData['name'];?>"> but i got access forbidden!
  8. Hello all! I'm makeing car booking module and have one problem. Explaining... There is tree joined tables "books", "car" and "cat". When i joining this three table it retrieves ids from table "car", but i want ids from "books" what to do? Can you help? Thanks <?php if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } $query = " SELECT * FROM books LEFT JOIN car ON books.car_id = car.id LEFT JOIN cat ON books.cat_id = cat.id WHERE books.owner = '$owner'"; $result = mysqli_query($db,$query) or die("Error: ".mysqli_error($db)); $myrow = mysqli_fetch_array($result, MYSQLI_BOTH); if(mysqli_num_rows($result) > 0){ if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } do { printf ('<tr> <td>'.$myrow["id"].'</td> <td>'.$myrow["model"].'</td> <td>'.$myrow["cat_name"].'</td> <td>'.$myrow["name"].'</td> <td>'.$myrow["surname"].'</td> <td>'.$myrow["country"].'</td> <td>'.$myrow["phone"].'</td> <td>'.$myrow["notes"].'</td> <td>'.$myrow["start_date"].'</td> <td>'.$myrow["end_date"].'</td> <td>'.$myrow["owner"].'</td> <td>'.$myrow["site"].'</td> <td><a href="delete.php?id='.$myrow["id"].'">Delete</a></td> </tr>'); } while ($myrow = mysqli_fetch_array($result)); } else{ echo '<p align="center" style="margin-top:100px;">There are no records...</p>'; } ?>
  9. hi once again im in need of help what i need is a double column one with a drop down box called type of business and one hidden one with the id, to me it would seem easier to simply code all of the options in html but the options for type of columns has been coded onto the website, i got a code sent over to me but errors are occurring so just wondering if anybody has any ideas. <td>Type of Business:</td> <select name="typeofbusiness" id="typeofbusiness"> <?php $count = count($_SESSION['typeofbusiness']); for ($i = 0; $i < $count; $i++) { if($_SESSION['id'][$i]!=$_SESSION['Id']){ ?> <option value="<?php echo $_SESSION['id'][$i];?>" <?php if (isset($_REQUEST['typeofbusiness'])&&$_REQUEST['typeofbusiness']==$_SESSION['id'][$i]) { echo'selected="selected"'; }?>><?php echo $_SESSION['typeofbusiness'][$i];?></option> <?php } } ?> ( ! ) Notice: Undefined variable: _SESSION in C:\wamp\www\AddLeads\addeadstemplate.php on line 248 Call Stack # Time Memory Function Location 1 0.0000 186688 {main}( ) ..\addeadstemplate.php:0 any help will be greatly appreciated.
  10. Hi guys, I am trying to pass an ID with a session to another page. -------- ID: 10 - edit link -------- ID: 11 - edit link -------- ID: 12 - edit link -------- The problem that I am having is that the session stored is always the last ID, in this case 12. $info["HostID"]; comes from the DB. <?php $link = $info["HostID"]; echo '<td><a href="edit.php?id='.$link.'">Edit</a></td>'; ?> <?php if(isset($_GET['$link'])){$_SESSION['hostid'] = $_GET['$link'];} ?> Any suggestions?
  11. cdmafra

    ID to GUID

    Hello. I'm writing this post to ask a question: how to "transform" ID fields to GUID? Is there any solution? If not, how can I create a GUID field/column in my MySQL table?
  12. i am trying to develop a registration form where the user fill the form and submit it then the status and the id should be displayed. i have used uniq_id function to generate a random id and with the help of this reference id i can retrieve the actual ID and display it back to the user. But unfortunately i am successful with the first registration after the first registration it throws an error that Error: "Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 9". my code: <?php include(conn.php); $id = $_GET['id']; $adv = $_GET['adv']; $name = $_GET['name']; $address = $_GET['address']; $pincode = $_GET['pincode']; $email = $_GET['email']; $fax = $_GET['fax']; $mobile = $_GET['mobile']; $amount = $_GET['amount']; $ddchno = $_GET['ddchno']; $bank = $_GET['bank']; $register = mysql_query( "insert into exbadv ( refid,adv,name,address,pincode,email,fax,mobile,amount,ddchno,bank) values ('$id','$adv','$name','$address','$pincode','$email','$fax','$mobile','$amount','$ddchno','$bank')"); $id = $_GET['id']; $result = mysql_query("SELECT id FROM exbadv WHERE refid = '$id'"); echo 'Your Registration id is ';echo mysql_result($result,0); ?> Plz help me out,thank u.
  13. i am trying to develop a registration form where the user fill the form and submit it then the status and the id should be displayed. i have used uniq_id function to generate a random id and with the help of this reference id i can retrieve the actual ID and display it back to the user. But unfortunately i am successful with the first registration after the first registration it throws an error that Error: "Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 9". my code: <?php include(conn.php); $id = $_GET['id']; $adv = $_GET['adv']; $name = $_GET['name']; $address = $_GET['address']; $pincode = $_GET['pincode']; $email = $_GET['email']; $fax = $_GET['fax']; $mobile = $_GET['mobile']; $amount = $_GET['amount']; $ddchno = $_GET['ddchno']; $bank = $_GET['bank']; $register = mysql_query( "insert into exbadv ( refid,adv,name,address,pincode,email,fax,mobile,amount,ddchno,bank) values ('$id','$adv','$name','$address','$pincode','$email','$fax','$mobile','$amount','$ddchno','$bank')"); $id = $_GET['id']; $result = mysql_query("SELECT id FROM exbadv WHERE refid = '$id'"); echo 'Your Registration id is ';echo mysql_result($result,0); ?> Plz help me out,thank u.
  14. Greetings all! I have simple question to do with a youtube plugin i use on my wordpress site. The plugin grabs the last digits of a Youtube webaddess and puts the youtube embed code into my wordpress Post area otherwise known as "post_inner_wrapper".... I have the code here supplied i simply wish to change were the PHP embed code will go, instead i want it to go to "Video_container" a Div i created in CSS. In the following code it uses "jf_yfvp_video_token" and / or "$video_token" to grab the video and embed the code so search Ctrl+f for "jf_yfvp_video_token" or "$video_token"... Any help would be apprecaatied as i am very newb at php and stil llearning. Thanks! <?php /* Plugin Name: YouTube Favorite Video Posts Description: Checks your YouTube favorite videos RSS feed and creates new posts in a custom post type. Version: 1.1 License: GPL2 */ /* Copyright 2011-2012 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Youtube_Favorite_Video_Posts_Foghlaim { public function __construct() { /* Things happen when we activate and deactivate the plugin of course. */ register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) ); register_deactivation_hook( __FILE__, array( $this, 'deactivate_plugin' ) ); /* Make a pretty link for settings under the plugin information. */ add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 ); /* Add our custom settings to the admin menu. */ add_action( 'admin_head', array( $this, 'edit_admin_icon' ) ); add_action( 'admin_menu', array( $this, 'add_settings' ) ); add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'add_languages' ) ); /* Register the jf_yfvp_youtube custom post type */ add_action( 'init', array( $this, 'create_content_type' ) ); /* Our hook added when we schedule a WP Cron event */ add_action( 'jf_yfvp_process_feed', array( $this, 'process_feed' ) ); } /** * When activating the plugin, register our custom post type and flush the rewrite * rules if the option to use our custom post type has been selected. */ public function activate_plugin(){ /* Create the custom post type upon activation. */ $this->create_content_type(); $current_options = get_option( 'jf_yfvp_options', array() ); $valid_fetch_intervals = wp_get_schedules(); /* If the custom post type provided by this plugin is selected, flush the rewrite * rules so that the URLs can be pretty */ if ( isset( $current_options['post_type'] ) && 'jf_yfvp_youtube' === $current_options['post_type'] ) flush_rewrite_rules( false ); /* If a fetch interval has previously been selected, use that. Otherwise, we'll not schedule the event until settings save. */ if ( isset( $current_options['fetch_interval'] ) && in_array( $current_options['fetch_interval'], $valid_fetch_intervals ) ) wp_schedule_event( ( time() + 120 ) , $current_options['fetch_interval'], 'jf_yfvp_process_feed' ); } /** * When the plugin is deactivated, we want to make sure that the WP Cron event * we have scheduled is cleared. */ public function deactivate_plugin(){ wp_clear_scheduled_hook( 'jf_yfvp_process_feed' ); } /** * Add the text domain for plugin translation */ public function add_languages() { load_plugin_textdomain( 'youtube-favorite-video-posts', false, basename( dirname( __FILE__ ) ) . '/lang' ); } /** * Add a link for the plugin settings page when viewing the general plugins display. * * Function gratefully borrowed from Pippin Williamson's WPMods article: * http://www.wpmods.com/adding-plugin-action-links/ * * @param $links array Current array of links to be displayed under the plugin * @param $file string The current plugin file being processed * @return array New array of links to be displayed under the plugin */ public function add_plugin_action_links( $links, $file ){ static $this_plugin; if ( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ ); if ( $file == $this_plugin ) { $settings_link = '<a href="' . site_url( '/wp-admin/options-general.php?page=youtube-favorite-video-posts-settings' ) . '">' . __( 'Settings', 'youtube-favorite-video-posts' ) . '</a>'; array_unshift( $links, $settings_link ); } return $links; } /** * Add some style to the plugin with a YouTube icon at the top of the page. */ public function edit_admin_icon(){ global $post_type; if ( 'jf_yfvp_youtube' === $post_type ) echo '<style>#icon-edit { background: url("' . plugins_url( 'images/youtube-icon-32.png', __FILE__ ) . '") no-repeat; background-size: 32px 32px; }</style>'; } /** * Add the sub-menu item under the Settings top-level menu. */ public function add_settings(){ add_options_page( __('YouTube Favorites', 'youtube-favorite-video-posts' ), __('YouTube Favorites', 'youtube-favorite-video-posts'), 'manage_options', 'youtube-favorite-video-posts-settings', array( $this, 'view_settings' ) ); } /** * Display the main settings view for Youtube Favorite Video Posts */ public function view_settings(){ ?> <div class="wrap"> <div class="icon32" id="icon-options-general"></div> <h2><?php _e( 'YouTube Favorite Video Posts', 'youtube-favorite-video-posts' ); ?></h2> <h3><?php _e( 'Overview', 'youtube-favorite-video-posts' ); ?>:</h3> <p style="margin-left:12px; max-width:640px;"><?php _e( 'The settings below will help determine where to check for your favorite YouTube videos, how often to look for them, and how they should be stored once new items are found.', 'youtube-favorite-video-posts' ); ?></p> <p style="margin-left:12px; max-width:640px;"><?php _e( 'The most important part of this process will be to determine the RSS feed for your favorite YouTube videos. To do this, your username <strong>must</strong> be filled out below. This can usually be found in the upper right hand corner of <a href="http://www.youtube.com">YouTube.com</a>.', 'youtube-favorite-video-posts' ); ?></p> <ol style="margin-left:36px;"> <li><?php _e( 'Username must be filled in below. Email address will not work.', 'youtube-favorite-video-posts' ); ?></li> <li><?php _e( 'The embed width and height settings will be applied to the iframe in your post content.', 'youtube-favorite-video-posts' ); ?></li> <li><?php _e( 'If you would like to change the content or title before the new content is saved, you may be interested in the <a href="http://jeremyfelt.com/wordpress/2012/05/12/filters-in-youtube-favorite-video-posts/">available filters</a>.', 'youtube-favorite-video-posts' ); ?></li> </ol> <form method="POST" action="options.php"> <?php settings_fields( 'jf_yfvp_options' ); do_settings_sections( 'jf_yfvp' ); ?> <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'youtube-favorite-video-posts' ); ?>" /></p> </form> </div> <?php } /** * Register the settings, sections, and fields that we want made available for * the plugin. */ public function register_settings(){ register_setting( 'jf_yfvp_options', 'jf_yfvp_options', array( $this, 'validate_options' ) ); add_settings_section( 'jf_yfvp_section_main', '', array( $this, 'main_section_text' ), 'jf_yfvp' ); add_settings_section( 'jf_yfvp_section_post_type', '', array( $this, 'post_type_section_text' ), 'jf_yfvp' ); add_settings_section( 'jf_yfvp_section_interval', '', array( $this, 'interval_section_text' ), 'jf_yfvp' ); add_settings_field( 'jf_yfvp_youtube_rss_feed', 'YouTube Username:', array( $this, 'youtube_user_text' ), 'jf_yfvp', 'jf_yfvp_section_main' ); add_settings_field( 'jf_yfvp_embed_width', 'Default Embed Width:', array( $this, 'embed_width_text' ), 'jf_yfvp', 'jf_yfvp_section_main' ); add_settings_field( 'jf_yfvp_embed_height', 'Default Embed Height:', array( $this, 'embed_height_text' ), 'jf_yfvp', 'jf_yfvp_section_main' ); add_settings_field( 'jf_yfvp_max_fetch_items', 'Max Items To Fetch:', array( $this, 'max_fetch_items_text' ), 'jf_yfvp', 'jf_yfvp_section_main' ); add_settings_field( 'jf_yfvp_post_type', 'Post Type:', array( $this, 'post_type_selection_text' ), 'jf_yfvp', 'jf_yfvp_section_post_type' ); add_settings_field( 'jf_yfvp_post_status', __( 'Default Post Status:', 'youtube-favorite-video-posts' ) , array( $this, 'post_status_selection_text' ), 'jf_yfvp', 'jf_yfvp_section_post_type' ); add_settings_field( 'jf_yfvp_fetch_interval', 'Feed Fetch Interval: ', array( $this, 'fetch_interval_selection_text' ), 'jf_yfvp', 'jf_yfvp_section_interval' ); } /** * Always seems weird to have to include this. */ public function main_section_text() { } /** * Describe the selection of a post type for the plugin to use. */ public function post_type_section_text() { ?> <h3>Custom Or Default Post Type</h3> <p style="margin-left:12px; max-width: 640px;"><?php _e( 'A new custom post type that adds an \'youtube\' slug to new items has been added and selected by default. You can change this to any other available post type if you would like.', 'youtube-favorite-video-posts' ); ?></p> <?php } /** * Describe the selection of the WP Cron interval we'll use */ public function interval_section_text() { $next_scheduled_time = wp_next_scheduled( 'jf_yfvp_process_feed' ); if ( $next_scheduled_time ) { $next_scheduled_time = $next_scheduled_time + ( get_option( 'gmt_offset' ) * 3600 ); $user_current_time = time() + ( get_option( 'gmt_offset' ) * 3600 ); $time_till_cron = human_time_diff( $user_current_time, $next_scheduled_time ); $next_cron_date = date( 'g:i:sa', $next_scheduled_time ); ?> <h3>RSS Fetch Frequency</h3> <p style="margin-left:12px; max-width: 630px;"><?php _e( 'This plugin currently depends on WP Cron operating fully as expected. In most cases, you should be able to select one of the intervals below and things will work. If not, please let <a href="http://www.jeremyfelt.com">me</a> know. By default, we check for new items on an hourly basis.', 'youtube-favorite-video-posts' ); ?></p> <p style="margin-left:12px; max-width: 630px;"><?php printf( __( 'Your Youtube favorites feed is scheduled to be loaded next in %1$s, at %2$s.', 'youtube-favorite-video-posts' ), $time_till_cron, $next_cron_date ); ?></p> <?php } else { ?> <h3>RSS Fetch Frequency</h3> <p style="margin-left:12px; max-width: 630px;"><?php _e( 'An interval has not yet been saved. Please select the frequency with which you would like this plugin to check your favorite video feed. The default of Once Hourly will be used if you do not change the interval before saving.', 'youtube-favorite-video-posts' ); ?></p> <?php } } /** * Provide an input for the embed width */ public function embed_width_text() { $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); if ( ! isset( $jf_yfvp_options['embed_width'] ) ) $jf_yfvp_options['embed_width'] = 330; ?> <input style="width: 100px;" type="text" id="jf_yfvp_embed_width" name="jf_yfvp_options[embed_width]" value="<?php echo esc_attr( $jf_yfvp_options['embed_width'] ); ?>" /> <?php } /** * Provide in input for the embed height */ public function embed_height_text() { $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); if ( ! isset( $jf_yfvp_options['embed_height'] ) ) $jf_yfvp_options['embed_height'] = 270; ?> <input style="width: 100px;" type="text" id="jf_yfvp_embed_height" name="jf_yfvp_options[embed_height]" value="<?php echo esc_attr( $jf_yfvp_options['embed_height'] ); ?>" /> <?php } /** * Provide an input for the Youtube username */ public function youtube_user_text() { $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); /* If options have been saved before, but no name specified, toss up a warning */ if ( ! empty( $jf_yfvp_options ) && empty( $jf_yfvp_options['youtube_rss_feed'] ) ) { ?> <div class="error" style="width: 615px;padding: 10px;"><?php _e( 'It looks like a Youtube username has not yet been entered, even though other options have been saved. Please note that we are unable to fetch your favorite videos until a username is provided.', 'youtube-favorite-video-posts' ); ?></div> <?php } if ( ! isset( $jf_yfvp_options['youtube_rss_feed'] ) ) $jf_yfvp_options['youtube_rss_feed'] = ''; ?> <input style="width: 200px;" type="text" id="jf_yfvp_youtube_rss_feed" name="jf_yfvp_options[youtube_rss_feed]" value="<?php echo esc_attr( $jf_yfvp_options['youtube_rss_feed'] ); ?>" /> <?php } /** * Provide an input for the selection of post types */ public function post_type_selection_text() { $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); if ( ! isset( $jf_yfvp_options['post_type'] ) ) $jf_yfvp_options['post_type'] = 'jf_yfvp_youtube'; $post_types = array_merge( get_post_types( array( '_builtin' => false ) ), array( 'post', 'link' ) ); echo '<select id="jf_yfvp_post_type" name="jf_yfvp_options[post_type]">'; foreach( $post_types as $pt ){ echo '<option value="' . esc_attr( $pt ) . '" ' . selected( $jf_yfvp_options['post_type'], $pt, false ) . '>' . esc_html( $pt ) . '</option>'; } echo '</select>'; } /** * Provide an input for the selection of post status */ public function post_status_selection_text() { $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); if ( ! isset( $jf_yfvp_options['post_status'] ) ) $jf_yfvp_options['post_status'] = 'publish'; $post_statii = array( 'draft', 'publish', 'private' ); echo '<select id="jf_yfvp_post_status" name="jf_yfvp_options[post_status]">'; foreach( $post_statii as $ps ) { echo '<option value="' . esc_attr( $ps ) . '" ' . selected( $jf_yfvp_options['post_status'], $ps, false ) . '>' . esc_html( $ps ) . '</option>'; } echo '</select>'; } /** * Provide an input to select the WP Cron interval to schedule the hook with */ public function fetch_interval_selection_text() { $intervals = wp_get_schedules(); $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); if ( ! isset( $jf_yfvp_options['fetch_interval'] ) ) $jf_yfvp_options['fetch_interval'] = 'hourly'; echo '<select id="jf_yfvp_fetch_interval" name="jf_yfvp_options[fetch_interval]">'; foreach( $intervals as $i => $v ){ echo '<option value="' . esc_attr( $i ) . '" ' . selected( $jf_yfvp_options['fetch_interval'], $i, false ) . '>' . esc_html( $v['display'] ) . '</option>'; } echo '</select>'; } /** * Provide an input for the max number of items to fetch */ public function max_fetch_items_text() { $jf_yfvp_options = get_option( 'jf_yfvp_options', array() ); if ( ! isset( $jf_yfvp_options['max_fetch_items'] ) ) $jf_yfvp_options['max_fetch_items'] = 5; ?> <input type="text" id="jf_yfvp_max_fetch_items" name="jf_yfvp_options[max_fetch_items]" value="<?php echo esc_attr( $jf_yfvp_options['max_fetch_items'] ); ?>" /> <?php } /** * Validate the options being saved for the plugin * * @param $input array New values that the user is attempting to save * @return array Validated values that we pass on */ public function validate_options( $input ) { $valid_post_status_options = array( 'draft', 'publish', 'private' ); $valid_fetch_interval_options = wp_get_schedules(); $valid_post_type_options = array_merge( get_post_types( array( '_builtin' => false ) ), array( 'post', 'link' ) ); if( ! in_array( $input['post_status'], $valid_post_status_options ) ) $input['post_status'] = 'publish'; if( ! in_array( $input['post_type'], $valid_post_type_options ) ) $input['post_type'] = 'jf_yfvp_youtube'; if( ! array_key_exists( $input['fetch_interval'], $valid_fetch_interval_options ) ) $input['fetch_interval'] = 'hourly'; /* It is possible the user just switched back to using our custom post type, so we should flush the rewrite rules */ if ( 'jf_yfvp_youtube' === $input['post_type'] ) flush_rewrite_rules( false ); /* This seems to be the only place we can reset the scheduled Cron if the frequency is changed, so here goes. */ wp_clear_scheduled_hook( 'jf_yfvp_process_feed' ); wp_schedule_event( ( time() + 30 ) , $input['fetch_interval'], 'jf_yfvp_process_feed' ); $input['max_fetch_items'] = absint( $input['max_fetch_items'] ); $input['embed_width'] = absint( $input['embed_width'] ); $input['embed_height'] = absint( $input['embed_height'] ); return $input; } /** * Register our custom post type - jf_yfvp_youtube - for possible use with the plugin */ public function create_content_type() { register_post_type( 'jf_yfvp_youtube', array( 'labels' => array( 'name' => __( 'YouTube', 'youtube-favorite-video-posts' ), 'singular_name' => __( 'YouTube Favorite', 'youtube-favorite-video-posts' ), 'all_items' => __( 'All YouTube Favorites', 'youtube-favorite-video-posts' ), 'add_new_item' => __( 'Add YouTube Favorite', 'youtube-favorite-video-posts' ), 'edit_item' => __( 'Edit YouTube Favorite', 'youtube-favorite-video-posts' ), 'new_item' => __( 'New YouTube Favorite', 'youtube-favorite-video-posts' ), 'view_item' => __( 'View YouTube Favorite', 'youtube-favorite-video-posts' ), 'search_items' => __( 'Search YouTube Favorites', 'youtube-favorite-video-posts' ), 'not_found' => __( 'No YouTube Favorites found', 'youtube-favorite-video-posts' ), 'not_found_in_trash' => __( 'No YouTube Favorites found in trash', 'youtube-favorite-video-posts' ), ), 'description' => __( 'YouTube posts created by the YouTube Favorite Video Posts plugin.', 'youtube-favorite-video-posts' ), 'public' => true, 'menu_icon' => plugins_url( '/images/youtube-icon-16.png', __FILE__ ), 'menu_position' => 5, 'hierarchical' => false, 'supports' => array ( 'title', 'editor', 'author', 'custom-fields', 'comments', 'revisions', ), 'has_archive' => true, 'rewrite' => array( 'slug' => 'youtube', 'with_front' => false ), ) ); } /** * The default SimplePie cache lifetime is 12 hours. We really do want to update more * frequently, so we'll make it 30 seconds during our update. * * @return int Number of seconds for the SimplePie cache to last */ public function modify_simplepie_cache_lifetime() { return 30; } /** * Grab the configured YouTube favorites RSS feed and create new posts based on that. * * @return mixed Only returns if leaving the function */ public function process_feed() { /* Go get some options! */ $youtube_options = get_option( 'jf_yfvp_options', array() ); /* No username, no feed. No feed, no work. */ if ( empty( $youtube_options['youtube_rss_feed'] ) ) return; /* The feed URL we'll be grabbing. */ $youtube_feed_url = 'http://gdata.youtube.com/feeds/base/users/' . esc_attr( $youtube_options['youtube_rss_feed'] ) . '/favorites?alt=rss'; if ( isset( $youtube_options['post_type'] ) ) $post_type = $youtube_options['post_type']; else $post_type = 'jf_yfvp_youtube'; if ( isset( $youtube_options['post_status'] ) ) $post_status = $youtube_options['post_status']; else $post_status = 'publish'; if ( isset( $youtube_options['max_fetch_items'] ) ) $max_fetch_items = absint( $youtube_options['max_fetch_items'] ); else $max_fetch_items = 5; /* Now fetch with the WordPress SimplePie function. */ add_filter( 'wp_feed_cache_transient_lifetime', array( $this, 'modify_simplepie_cache_lifetime' ) ); $youtube_feed = fetch_feed( $youtube_feed_url ); remove_filter( 'wp_feed_cache_transient_lifetime', array( $this, 'modify_simplepie_cache_lifetime' ) ); if ( ! is_wp_error( $youtube_feed ) ) { $max_items = $youtube_feed->get_item_quantity( $max_fetch_items ); $youtube_items = $youtube_feed->get_items( 0, $max_items ); foreach( $youtube_items as $item ) { // Hash the guid element from the RSS feed to determine uniqueness, since yeah... guid. $video_guid = md5( $item->get_id() ); $video_token = substr( $item->get_id(), 43 ); $old_item_hash = md5( $video_token ); $video_embed_code = '<iframe width=\"' . absint( $youtube_options['embed_width'] ) . '\" height=\"' . absint( $youtube_options['embed_height'] ) . '\" src=\"http://www.youtube.com/embed/' . esc_attr( $video_token ) . '\" frameborder=\"0\" allowfullscreen></iframe>'; /* Allow other plugins or themes to alter or replace the post content before storing */ $video_embed_code = apply_filters( 'yfvp_new_video_embed_code', $video_embed_code, $video_token ); /* Allow other plugins or themes to alter or replace the post title before storing. * Also, we're disabling the kses filters below, so we need to clean up the title as * YouTube allows " and the like. */ $original_item_title = $item->get_title(); $item_title = esc_html( apply_filters( 'yfvp_new_video_item_title', $original_item_title ) ); /** * Our previous hash management was ugly, so now we need to check for the * existence of the old hash before checking the existence of the new hash. * If we do happen to find an old hash, we'll update it immediately with * the newer hash so that we can get rid of this code in the next release. */ $existing_old_item = get_posts( array( 'post_type' => $post_type, 'numberposts' => 1, 'post_status' => array( 'publish', 'draft', 'private' ), 'meta_query' => array( array( 'key' => 'jf_yfvp_hash', 'value' => $old_item_hash, ), ), )); if ( ! empty( $existing_old_item ) ) { update_post_meta( $existing_old_item[0]->ID, 'jf_yfvp_hash', $video_guid ); $existing_items = $existing_old_item; } else { $existing_items = get_posts( array( 'post_type' => $post_type, 'numberposts' => 1, 'post_status' => array( 'publish', 'draft', 'private' ), 'meta_query' => array( array( 'key' => 'jf_yfvp_hash', 'value' => $video_guid, ), ), )); } // If we come back empty on our meta query, we should be ok to insert the video as normal if ( empty ( $existing_items ) ) { $youtube_post = array( 'post_title' => $item_title, 'post_content' => $video_embed_code, 'post_author' => 1, 'post_status' => $post_status, 'post_type' => $post_type, 'filter' => true, ); kses_remove_filters(); $item_post_id = wp_insert_post( $youtube_post ); kses_init_filters(); add_post_meta( $item_post_id, 'jf_yfvp_hash', $video_guid, true ); add_post_meta( $item_post_id, 'jf_yfvp_video_token', $video_token, true ); add_post_meta( $item_post_id, 'jf_yfvp_original_title', sanitize_title( $original_item_title ), true ); } else { $original_meta_title = get_post_meta( $existing_items[0]->ID, 'jf_yfvp_original_title', true ); /* * If the current item's original title does not match the matched post's original title, * update it with the current filtered version of the new item title. *whew* */ if ( $original_item_title !== $original_meta_title ) { wp_update_post( array( 'ID' => $existing_items[0]->ID, 'post_title' => $item_title ) ); update_post_meta( $existing_items[0]->ID, 'jf_yfvp_original_title', $original_item_title ); } } } } } } new Youtube_Favorite_Video_Posts_Foghlaim();
  15. Hello, I am new to php i was wondering if anyone can help me basically i have been assigned to create a database where you have four questions and four answers and the database should display the four questions and next to them would say "incorrect" or "correct" if you click on the button if this makes sense here is my html code but I have no idea on how get php to place it into the database, i tried to use Div/ID tags to help but i haven't got a clue what i am doing <img src="Images/Question1.png" usemap="#mainMap" id="main" style="position:absolute;display:none;left:0px;top:0px;" border="0" /> <map name="mainMap" id="mainMap"> <div id="Incorrectanswer1"><area shape="rect" coords="82,192,196,242" onclick="incorrectAnswer()" /></div> <div id="Incorrectanswer2"><area shape="rect" coords="83,254,197,300" onclick="incorrectAnswer()" /></div> <div id="Incorrectanswer3"><area shape="rect" coords="83,310,201,368" onclick="incorrectAnswer()" /></div> <div id="Correctanswer1"><area shape="rect" coords="84,373,205,430" onclick="correctAnswer()" /></div> </map> if anyone could help or point me in the right direction this would be helpful. Thanks, Jonathan Jones
  16. Hi. I have many iframes on a page. This script dynamically resizes the height of each iframes content. I would like one iframe to not dynamically resize its iframe content height. i have tried adding the id code but it is not working. eg, document.getElementById("iframe").style.height=height+"px" <script type='text/javascript'> $(function(){ var iFrames = $('iframe'); function iResize() { for (var i = 0, j = iFrames.length; i < j; i++) { iFrames[i].style.height = iFrames[i].contentwindow.document.body.offsetHeight + 'px';} } if ($.browser.safari || $.browser.opera) { iFrames.load(function(){ setTimeout(iResize, 0); }); for (var i = 0, j = iFrames.length; i < j; i++) { var iSource = iFrames[i].src; iFrames[i].src = ''; iFrames[i].src = iSource; } } else { iFrames.load(function() { this.style.height = this.contentwindow.document.body.offsetHeight + 'px'; }); } }); </script>
×
×
  • 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.