Jump to content

Search the Community

Showing results for tags 'code'.

  • 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

  1. if($balance >= $cashout){ $mysqli->query("UPDATE balances SET balance=balance-$balance WHERE email='$email'"); $balanceQ = $mysqli->query("SELECT balance FROM balances WHERE email='$email'"); //we check again to prevent race attacks if($balanceQ->fetch_row() >= 0){ $url = "https://inputs.io/api?key=$apiKey&action=send&address=&amount=&note=&pin=$apiPin" . urlencode($cashoutMessage . " | MyFaucet Powered") . "&address=" . urlencode($email) . "&amount=" . ($balance / 100000000); $response = file_get_contents($url); if($response[0] == "["){ //success echo "<div class='alert alert-success'>Successful cashout to $email - enjoy!</div>"; } else { echo "<div class='alert alert-error'>An error has occured - $response</div>"; if($response == "NO_BALANCE"){ echo "<div class='alert alert-error'>The site does not have enough coins to pay out!</div>"; $mysqli->query("UPDATE balances SET balance=balance+$balance WHERE email='$email'"); Im having problems when people go cashout and they get error page i think the problem is $url but i dont know if you want to find out the api go here https://inputs.io/api and head to send transactions so from there i dont know what else to do.
  2. Dont know what to do kinda new to php.
  3. Hello everyone! I've just started learning php and I've been doing alot of different tasks to test myself and what I've learned. I'm currently trying to do this exercise and I think I got it sorted, at least most of it but I need your help sorting out of my coding is good, and how to finish the last task Here is what I need to do: XXX AS is a company with a number of employees. The company wants a webpage that shows a table of employee data with information regarding their names, gender, date of birth, position, position start date, gross salary, tax amount, pension and amount of net salary. 1: Create your own list of employees and store employee data in an array. 2: Tax amount is based on gross salary amount as following: less than 100k is tax free 100,000 <200,000 is 10 % tax 200,000 <300,000 is 20% 300,000 <500,000 is 35% >500,000 is 45% 3: 2.5 % pension is to be decuted from all gross salary 4: Show all momentary amounts with the two decimal places and thousand separators. This is what I've done so far: <?php /*****GROSS SALARY***** Creates the variabel containing the gross salary data for each employee*/ /*Aron*/ $gross_salary1 = 635000.00; /*Britney*/ $gross_salary2 = 420000.00; /*Daniel*/ $gross_salary3 = 260000.00; /*Jessica*/ $gross_salary4 = 350000.00; /*Peter*/ $gross_salary5 = 250000.00; /*Keith*/ $gross_salary6 = 90000.00; /*****PENSION***** Creates the variabel to deduct pension*/ $pension = 0.025; /*****TAXATION***** /* Creates if statements that runs trough the salaries and deducts tax rate accordingly for each employee*/ /* Aron and taxes*/ if ($gross_salary1 >= 500000) { $tax1=0.45; } if ($gross_salary1 >= 300000 and $gross_salary1 < 500000) { $tax1=0.35; } if ($gross_salary1 >= 200000 and $gross_salary1 < 300000) { $tax1=0.2; } if ($gross_salary1 >= 100000 and $gross_salary1 < 200000) { $tax1=0.1; } if ($gross_salary1 < 100000) { $tax1=0; } /* Britney and taxes*/ if ($gross_salary2 >= 500000) { $tax2=0.45; } if ($gross_salary2 >= 300000 and $gross_salary2 < 500000) { $tax2=0.35; } if ($gross_salary2 >= 200000 and $gross_salary2 < 300000) { $tax2=0.2; } if ($gross_salary2 >= 100000 and $gross_salary2 < 200000) { $tax2=0.1; } if ($gross_salary2 < 100000) { $tax2=0; } /* Daniel and taxes*/ if ($gross_salary3 >= 500000) { $tax3=0.45; } if ($gross_salary3 >= 300000 and $gross_salary3 < 500000) { $tax3=0.35; } if ($gross_salary3 >= 200000 and $gross_salary3 < 300000) { $tax3=0.2; } if ($gross_salary3 >= 100000 and $gross_salary3 < 200000) { $tax3=0.1; } if ($gross_salary3 < 100000) { $tax3=0; } /* Jessica and taxes*/ if ($gross_salary4 >= 500000) { $tax4=0.45; } if ($gross_salary4 >= 300000 and $gross_salary4 < 500000) { $tax4=0.35; } if ($gross_salary4 >= 200000 and $gross_salary4 < 300000) { $tax4=0.2; } if ($gross_salary4 >= 100000 and $gross_salary4 < 200000) { $tax4=0.1; } if ($gross_salary4 < 100000) { $tax4=0; } /* Peter and taxes*/ if ($gross_salary5 >= 500000) { $tax5=0.45; } if ($gross_salary5 >= 300000 and $gross_salary5 < 500000) { $tax5=0.35; } if ($gross_salary5 >= 200000 and $gross_salary5 < 300000) { $tax5=0.2; } if ($gross_salary5 >= 100000 and $gross_salary5 < 200000) { $tax5=0.1; } if ($gross_salary5 < 100000) { $tax5=0; } /* Keitd and taxes*/ if ($gross_salary6 >= 500000) { $tax6=0.45; } if ($gross_salary6 >= 300000 and $gross_salary6 < 500000) { $tax6=0.35; } if ($gross_salary6 >= 200000 and $gross_salary6 < 300000) { $tax6=0.2; } if ($gross_salary6 >= 100000 and $gross_salary6 < 200000) { $tax6=0.1; } if ($gross_salary6 < 100000) { $tax6=0; } /*****ABC ARRAY***** /*Sorts all the employees in a multiarray, and also does the tax-pension-salary*/ $abc = array( 'e_1'=>array ('Aron','M','1930/01/25','Manager','1998/01/01',number_format($gross_salary1,2,".",","),number_format($gross_salary1*$tax1,2,".",","),number_format($gross_salary1*$pension,2,".",","),number_format($gross_salary1-$gross_salary1*$pension-$gross_salary1*$tax1,2,".",",")), 'e_2'=>array ('Britney','F','2001/05/06','Researcher','2001/03/15',number_format($gross_salary2,2,".",","),number_format($gross_salary2*$tax2,2,".",","),number_format($gross_salary2*$pension,2,".",","),number_format($gross_salary2-$gross_salary2*$pension-$gross_salary2*$tax2,2,".",",")), 'e_3'=>array ('Daniel','M','2003/01/15','Officer','2003/12/06',number_format($gross_salary3,2,".",","),number_format($gross_salary3*$tax3,2,".",","),number_format($gross_salary3*$pension,2,".",","),number_format($gross_salary3-$gross_salary3*$pension-$gross_salary3*$tax3,2,".",",")), 'e_4'=>array ('Jessica','F','2002/11/21','Officer','2007/02/20',number_format($gross_salary4,2,".",","),number_format($gross_salary4*$tax4,2,".",","),number_format($gross_salary4*$pension,2,".",","),number_format($gross_salary4-$gross_salary4*$pension-$gross_salary4*$tax4,2,".",",")), 'e_5'=>array ('Peter','M','1998/01/07','Assisant','2009/09/06',number_format($gross_salary5,2,".",","),number_format($gross_salary5*$tax5,2,".",","),number_format($gross_salary5*$pension,2,".",","),number_format($gross_salary5-$gross_salary5*$pension-$gross_salary5*$tax5,2,".",",")), 'e_6'=>array ('Keitd','M','2003/07/25','Intern','2012/06/27',number_format($gross_salary6,2,".",","),number_format($gross_salary6*$tax6,2,".",","),number_format($gross_salary6*$pension,2,".",","),number_format($gross_salary6-$gross_salary6*$pension-$gross_salary6*$tax6,2,".",","))); /*Sorts the employee array by the names of the employees by default when loading the page*/ array_multisort($abc,SORT_ASC); /*****TABLE&SUCH****** /*defines the border scale */ echo '<table border="7">'; /*Prints out a table witd all the information headlines regarding the table and its employees*/ echo '<tr><td><center><strong><big>','Name','</strong></big></center></td>' .'<td><center><strong><big>', 'Gender','</strong></big></center></td>' .'<td><center><strong><big>', 'DOB','</strong></big></center></td>' .'<td><center><strong><big>', 'Position','</center></strong></big></td>' .'<td><center><strong><big>', 'Start Date','</strong></big></center></td>' .'<td><strong><big>','Gross Salary','</strong></big></td>' .'<td><center><strong><big>', 'Tax','</center></strong></big></td>' .'<td><center><strong><big>', 'Pension','</center></strong></big></td>' .'<td><center><strong><big>', 'Net Salary','</strong></big></center></td>'; /*Puts the data of the employees into the table*/ foreach ($abc as $abct) { echo '<tr><td><div align="left">', $abct[0],'</div></td>' .'<td><center>', $abct[1],'</center></td>' .'<td><center>', $abct[2],'</center></td>' .'<td><div align="left">', $abct[3],'</div></td>' .'<td><center>', $abct[4],'</center></td>' .'<td><div align="right">', $abct[5],'</div></td>' .'<td><div align="right">', $abct[6],'</div></td>' .'<td><div align="right">', $abct[7],'</div></td>' .'<td><div align="right">', $abct[8],'</div></td>' . '</tr>'; } echo '</table>';/*Ends the table*/ ?> Any help on sorting the code better would be appreciated Again I'm not the best.. AND I would love help with the last task which is: 5: The page should show the listing of the data in a sorted order depending on a selected sort field and sort order (ascending and descending). The default sorting should be by name. Thanks guys you're awsome <3
  4. I am a learner of php. So i just joined with you. I need help to understand the php code. I have seen a php file. where has a line of code was $CI =& get_instance() so Please explane me the line of code. Full code of the file given bellow ------------------------------------------------------------------------------------- if (!defined('BASEPATH')) exit('No direct script access allowed');require_once(FUEL_PATH.'models/base_module_model.php');class Courses_model extends Base_module_model { public $record_class = 'Course'; public $required = array( 'title' => 'Please fill out the course name', 'slug' => 'Slug cannot be empty', ); function __construct() { $CI =& get_instance(); $this->config->module_load(COURSE_FOLDER, COURSE_FOLDER); $this->_tables = $CI->config->item('tables'); parent::__construct($this->_tables['courses']); $this->load->module_model(COURSE_FOLDER, 'lessons_model'); } function list_items($limit = NULL, $offset = NULL, $col = 'title', $order = 'asc') { $data = parent::list_items($limit, $offset, $col, $order); return $data; } function form_fields($values = array()) { $fields = parent::form_fields($values); unset($fields['created_at']); return $fields; } function get_courses($where = array(), $order_by ='title', $limit = NULL, $offset = NULL, $return_method = NULL, $assoc_key = NULL) { $courses = $this->db->get($this->_tables['courses'])->result_array(); if($courses) { foreach($courses as &$course) { $course['lessons'] = $this->db->where(array('course_id' => $course['id']))->get($this->_tables['lessons'])->result_array(); if(is_array($course['lessons'])) { foreach ($course['lessons'] as $key => &$lesson) { $lesson['articles_count'] = $this->db->where(array('lesson_id' => $lesson['id']))->get($this->_tables['articles'])->num_rows(); } } } } return $courses; }}class Course_model extends Base_module_record { private $_tables; function on_init() { $this->_tables = $this->_CI->config->item('tables'); }}
  5. Hi all, I've a problem with my PHP code. I've a page, where you can select multiple pages, which will be displayed at the related section on my site. So far, you can select the pages, and they will be injected into the database, and they will be displayed on the site. My only problem is: the pages won't be selected on the edit page. I've this piece of code, and I don't know what I'm doing wrong. <?php $id = $_POST["id"]; $sql=mysql_query("SELECT `title`,`url`,`volg`, `headerpicture`, `picture`, `product_id` FROM `pagina` WHERE `id`='".$id."' LIMIT 0,1"); $row=mysql_fetch_assoc($sql); echo '<select MULTIPLE name="related[]">'; if ($row['related'] != '') $related_array=explode(',',$row['related']); else $related_array=array(); $query="SELECT `id` FROM `producten`"; $sql=mysql_query($query) or die(mysql_error()); while($line=mysql_fetch_array($sql)) { $query1="SELECT `title` FROM `pagina` WHERE `product`=1 AND `product_id`='".$line['id']."'"; $sql1=mysql_query($query1); if(mysql_num_rows($sql1) >0) { $line1=mysql_fetch_array($sql1); $selected=' '; foreach($related_array as $related_line) { if ($related_line == $line['id']) $selected=' selected '; } echo '<option'.$selected.'value="'.$line['id'].'">'.$line1['title'].'</option>'; } } echo '</select>'; ?> What am I doing wrong? Is there a piece of code I need to script?
  6. Hello, I'm here with a question that maybe silly for most of you but I just can't handle it. As I know, there's no way in built in PHP inside JS because diferent kind of languages ( Server Side and Client Side ). But I have a problem that I need help to handle. I have a multilanguage system in my site ( PHP ) and form validations ( JS ). I have the error messages showed by JS instantly, but I can only print text, not a PHP variable info. For example: $(function() { // validate signup form on keyup and submit $("#loginform").validate({ rules: { user: "required", password: "required", }, messages: { user: "Please enter your username or email.", password: "Please enter your password", } }); }); And my multilanguage system uses the following system: $lang['login_error'] = 'Incorrect details provided.'; There is any way to make something like this: $(function() { // validate signup form on keyup and submit $("#loginform").validate({ rules: { user: "required", password: "required", }, messages: { user: <?php echo $lang[login_error']; ?>, password: "Please enter your password", } }); }); I know this doesn't work, but it's to make an easy example in what I need, because depending the language the user as choosen, the error should be there in that language, not only in one language. Could you please help me to handle this ? Thanks in advance.
  7. So a friend and I have recently started coding a simple posting webpage. At the moment we are trying to make a like button to like other posts but we are having trouble. We have made this like button and it works kind of right, the only problem is that when we click it, it adds a like to all the posts not just the one we click. Since we are trying to make a very simple page for now, we would like to keep the amount of files to a minimum and so we can not, nor would we like to, use the facebook like button. We are using Wamp, I don't think that would be relevant just like to add it in there. connection.php wall.php
  8. Hey I'm new to php and I have a bit of a problem. I haven't edited anything on this page, but keep getting a Parse error: syntax error, unexpected T_LNUMBER on line 64. Does anyone see the mistake or could help me in any way? Thank you. <?php // Set Content Width if ( ! isset( $content_width ) ) $content_width = 480; /*==================================== THEME SETUP ====================================*/ // Load default style.css and Javascripts add_action('wp_enqueue_scripts', 'themezee_enqueue_scripts'); if ( ! function_exists( 'themezee_enqueue_scripts' ) ): function themezee_enqueue_scripts() { // Register and Enqueue Stylesheet wp_register_style('zeeBusiness_stylesheet', get_stylesheet_uri()); wp_enqueue_style('zeeBusiness_stylesheet'); // Enqueue jQuery Framework wp_enqueue_script('jquery'); // Register and enqueue the Malsup Cycle Plugin wp_register_script('zee_jquery-cycle', get_template_directory_uri() .'/includes/js/jquery.cycle.all.min.js', array('jquery')); wp_enqueue_script('zee_jquery-cycle'); } endif; // Load comment-reply.js if comment form is loaded and threaded comments activated add_action( 'comment_form_before', 'themezee_enqueue_comment_reply' ); function themezee_enqueue_comment_reply() { if( get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } // Setup Function: Registers support for various WordPress features add_action( 'after_setup_theme', 'themezee_setup' ); if ( ! function_exists( 'themezee_setup' ) ): function themezee_setup() { // init Localization load_theme_textdomain('themezee_lang', get_template_directory() . '/includes/lang' ); // Add Theme Support add_theme_support('post-thumbnails'); add_theme_support('automatic-feed-links'); add_editor_style(); // Add Custom Background add_theme_support('custom-background', array('default-color' => 'eee')); // Add Custom Header add_theme_support('custom-header', array( 'default-image' => get_template_directory_uri() . '/images/default_header.jpg', 'header-text' => false, 'width' => 1100, 'height' => 140, 'flex-height' => true)); // Register Navigation Menus register_nav_menu( 'top_navi', __('Top Navigation', 'themezee_lang') ); register_nav_menu( 'main_navi', __('Main Navigation', 'themezee_lang') ); register_nav_menu( 'foot_navi', __('Footer Navigation', 'themezee_lang') );
  9. Hi, I want to change this code to show time from current just for today. you can see on the webiste there is time from tomorrow but not from morning , but from current time. this is the code. can you please help ? http://www.dublincitycouriers.com/index2.php <label>Pickup Time</label> <select name="pickuptime"> <? $i=date('G', time()); $i++; while($i<18) { $date = gmmktime($i, 0, 0, gmdate("m") , gmdate("j",$selectDate), gmdate("Y")); if($date==$_SESSION['pickuptime']) { echo "<option selected value=\"".$i."\">".gmdate('H:00',$date)."</option>"; } else { echo "<option value=\"".$i."\">".gmdate('H:00',$date)."</option>"; } $i++; } ?>
  10. Hello, okay, so I need some help, before i start i must warn you that i'm not very good at explaining. Using a WYSIWYG Web Builder i have built a website with a membership system. Now when i make an account with the membership system, and enter the password 'htmlforums' it will show '2810bd8735116c769d9d4f6d6b53c3e1' in my mySQL database. Now I have also downloaded a forum script and have linked the two to the same database. The only problem is that the user password is different and therefore both don't work with one user. If make an account with the same password using the forums script it will show '2a9e532f806c272ecb01d58c503bc9a96f7b3ad8' in my mySQL database under passowrd. So both use a different system to login, but if i manually change the password's in the database (swap them) they will work, (as in with password one (2810bd8735116c769d9d4f6d6b53c3e1), i can sign in to the site and if i change it password 2 (2a9e532f806c272ecb01d58c503bc9a96f7b3ad8) i can sign in to the forum) so i'm not far off. I have very little knowledge of how they work, so can someone help me to get them both generating and accepting the same password. P.S I can't edit the code from the WYSIWYG web builder, as it generates it automatically. Here is the code for the login page by the WYSIWYG Web Builder. <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'loginform') { session_start(); $success_page = isset($_SESSION['page_from'])?$_SESSION['page_from']:'/../../library/'; $error_page = basename(__FILE__); $mysql_server = 'localhost'; $mysql_username = '???????'; $mysql_password = '???????'; $mysql_database = '???????'; $mysql_table = 'USERS'; $crypt_pass = md5($_POST['password']); $found = false; $fullname = ''; $db = mysql_connect($mysql_server, $mysql_username, $mysql_password); if (!$db) { die('Failed to connect to database server!<br>'.mysql_error()); } mysql_select_db($mysql_database, $db) or die('Failed to select database<br>'.mysql_error()); $sql = "SELECT password, fullname, active FROM ".$mysql_table." WHERE username = '".mysql_real_escape_string($_POST['username'])."'"; $result = mysql_query($sql, $db); if ($data = mysql_fetch_array($result)) { if ($crypt_pass == $data['password'] && $data['active'] != 0) { $found = true; $fullname = $data['fullname']; } } mysql_close($db); if($found == false) { header('Location: '.$error_page); exit; } else { if (session_id() == "") { session_start(); } $_SESSION['username'] = $_POST['username']; $_SESSION['fullname'] = $fullname; $rememberme = isset($_POST['rememberme']) ? true : false; if ($rememberme) { setcookie('username', $_POST['username'], time() + 3600*24*30); setcookie('password', $_POST['password'], time() + 3600*24*30); } header('Location: '.$success_page); exit; } } $username = isset($_COOKIE['username']) ? $_COOKIE['username'] : ''; $password = isset($_COOKIE['password']) ? $_COOKIE['password'] : ''; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Login</title> <meta name="description" content="Login page for Techyoucation.com"> <meta name="keywords" content="techyoucation, tutorials, technology, under construction,"> <meta name="author" content="Aled Daniel Evans"> <meta name="categories" content="Technology, Tutorials"> <link rel="shortcut icon" href="icon.ico"> <link rel="stylesheet" href="Site.css" type="text/css"> <link rel="stylesheet" href="index.css" type="text/css"> <script type="text/javascript" src="jquery-1.7.2.min.js"></script> <script type="text/javascript" src="wb.stickylayer.min.js"></script> <script type="text/javascript" src="jquery.effects.core.min.js"></script> <script type="text/javascript" src="jquery.effects.blind.min.js"></script> <script type="text/javascript" src="jquery.effects.bounce.min.js"></script> <script type="text/javascript" src="jquery.effects.clip.min.js"></script> <script type="text/javascript" src="jquery.effects.drop.min.js"></script> <script type="text/javascript" src="jquery.effects.explode.min.js"></script> <script type="text/javascript" src="jquery.effects.fold.min.js"></script> <script type="text/javascript" src="jquery.effects.highlight.min.js"></script> <script type="text/javascript" src="jquery.effects.pulsate.min.js"></script> <script type="text/javascript" src="jquery.effects.scale.min.js"></script> <script type="text/javascript" src="jquery.effects.shake.min.js"></script> <script type="text/javascript" src="jquery.effects.slide.min.js"></script> <script type="text/javascript" src="../../searchindex.js"></script> <script type="text/javascript"> <!-- var features = 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,left=,top=,width=,height='; var searchDatabase = new SearchDatabase(); var searchResults_length = 0; var searchResults = new Object(); function searchPage(features) { var element = document.getElementById('search_box_keyword'); if (element.value.length != 0 || element.value != " ") { var value = unescape(element.value); var keywords = value.split(" "); searchResults_length = 0; for (var i=0; i<database_length; i++) { var matches = 0; var words = searchDatabase[i].title + " " + searchDatabase[i].description + " " + searchDatabase[i].keywords; for (var j = 0; j < keywords.length; j++) { var pattern = new RegExp(keywords[j], "i"); var result = words.search(pattern); if (result >= 0) { matches++; } else { matches = 0; } } if (matches == keywords.length) { searchResults[searchResults_length++] = searchDatabase[i]; } } var wndResults = window.open('about:blank', '', features); setTimeout(function() { var html = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Search results<\/title><\/head>'; html = html + '<body style="background-color:#FFFFFF;margin:0;padding:2px 2px 2px 2px;">'; html = html + '<span style="font-family:Arial;font-size:13px;color:#000000">'; for (var n=0; n<searchResults_length; n++) { html = html + '<b><a style="color:#0000FF" target="_parent" href="'+searchResults[n].url+'">'+searchResults[n].title +'<\/a><\/b><br>Description:' + searchResults[n].description + '<br>Keywords:' + searchResults[n].keywords +'<br><br>\n'; } if (searchResults_length == 0) { html = html + 'No results'; } html = html + '<\/span>'; html = html + '<\/body><\/html>'; wndResults.document.write(html); },100); } return false; } // --> </script> <script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script> <script src="cookieControl-5.1.min.js" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ cookieControl({ introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>', fullText:'<p>Some of these cookies are essential to make our site work and have already been set. Others help us to improve by giving us some insight into how the site is being used or help to improve the experience of using our site but will only be set if you consent.</p><p>By using our site you accept the terms of our <a href="http://www.whatnews.co.uk/privacy">Privacy Policy</a></p>', position:'left', // left or right shape:'triangle', // triangle or diamond theme:'light', // light or dark startOpen:true, autoHide:3000, subdomains:true, protectedCookies: ['analytics', 'twitter'], //list the cookies you do not want deleted ['analytics', 'twitter'] consentModel:'implicit', onAccept:function(){ccAddAnalytics()}, onReady:function(){}, onCookiesAllowed:function(){ccAddAnalytics()}, onCookiesNotAllowed:function(){}, countries:'United Kingdom,Netherlands' // Or supply a list ['United Kingdom', 'Greece'] }); function ccAddAnalytics() { jQuery.getScript("http://www.google-analytics.com/ga.js", function() { var GATracker = _gat._createTracker(''); GATracker._trackPageview(); }); } //]]> </script> <script type="text/javascript" src="./wwb8.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#FB-Over a").hover(function() { $(this).children("span").stop().fadeTo(200, 0); }, function() { $(this).children("span").stop().fadeTo(200, 1); }) $("#G-Over a").hover(function() { $(this).children("span").stop().fadeTo(200, 0); }, function() { $(this).children("span").stop().fadeTo(200, 1); }) $("#T-Over a").hover(function() { $(this).children("span").stop().fadeTo(200, 0); }, function() { $(this).children("span").stop().fadeTo(200, 1); }) $("#YT-Over a").hover(function() { $(this).children("span").stop().fadeTo(200, 0); }, function() { $(this).children("span").stop().fadeTo(200, 1); }) $("#Layer3").stickylayer({orientation: 1, position: [0, 0], delay: 0}); $("#RollOver1 a").hover(function() { $(this).children("span").stop().fadeTo(500, 0); }, function() { $(this).children("span").stop().fadeTo(500, 1); }) $("#header_inc_layer1").stickylayer({orientation: 2, position: [0, 0], delay: 0}); var $search = $('#search_box_form'); var $searchInput = $search.find('input'); var $searchLabel = $search.find('label'); if ($searchInput.val()) { $searchLabel.hide(); } $searchInput.focus(function() { $searchLabel.hide(); }).blur(function() { if (this.value == '') { $searchLabel.show(); } }); $searchLabel.click(function() { $searchInput.trigger('focus'); }); }); </script> <!--[if lt IE 7]> <style type="text/css"> img { behavior: url("pngfix.htc"); } </style> <![endif]--> <!-- no cache headers --> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="no-cache"> <meta http-equiv="Expires" content="-1"> <meta http-equiv="Cache-Control" content="no-cache"> <!-- end no cache headers --> </head> <body> <div id="container"> <div id="wb_Shape1" style="position:absolute;left:3px;top:74px;width:994px;height:412px;z-index:66;"> <img src="images/img0010.png" id="Shape1" alt="" style="border-width:0;width:994px;height:412px;"></div> <div id="wb_Text1" style="position:absolute;left:33px;top:103px;width:102px;height:29px;z-index:67;text-align:left;"> <span style="color:#2A2B30;font-family:Arial;font-size:24px;"><strong>Login</strong></span></div> <hr id="Line1" style="margin:0;padding:0;position:absolute;left:30px;top:155px;width:933px;height:1px;z-index:68;"> <div id="wb_Text2" style="position:absolute;left:30px;top:166px;width:76px;height:12px;text-align:justify;z-index:69;"> <span style="color:#D9D9D9;font-family:Arial;font-size:9.3px;">PLEASE LOGIN</span></div> <div id="wb_loginform" style="position:absolute;left:336px;top:218px;width:322px;height:214px;z-index:70;"> <form name="loginform" method="post" action="<?php echo basename(__FILE__); ?>" id="loginform"> <input type="hidden" name="form_name" value="loginform"> <div id="wb_Text6" style="position:absolute;left:45px;top:118px;width:91px;height:16px;z-index:58;text-align:left;"> <span style="color:#666666;font-family:Arial;font-size:13px;">Remember me</span></div> <input type="checkbox" id="rememberme" name="rememberme" value="on" style="position:absolute;left:23px;top:117px;z-index:59;"> <input type="submit" id="login_button" name="login" value="Log In" style="position:absolute;left:92px;top:148px;width:138px;height:33px;z-index:60;"> <div id="wb_Shape2" style="position:absolute;left:23px;top:16px;width:283px;height:40px;z-index:61;"> <img src="images/img0011.png" id="Shape2" alt="" style="border-width:0;width:283px;height:40px;"></div> <div id="wb_Shape3" style="position:absolute;left:23px;top:66px;width:283px;height:40px;z-index:62;"> <img src="images/img0012.png" id="Shape3" alt="" style="border-width:0;width:283px;height:40px;"></div> <input type="text" id="username" style="position:absolute;left:23px;top:16px;width:280px;height:38px;line-height:38px;z-index:63;" name="username" value="<?php echo $username; ?>Username" autocomplete="off"> <input type="password" id="password" style="position:absolute;left:23px;top:66px;width:280px;height:38px;line-height:38px;z-index:64;" name="password" value="<?php echo $password; ?> Password" autocomplete="off"> <div id="wb_Text3" style="position:absolute;left:83px;top:185px;width:160px;height:16px;z-index:65;text-align:left;"> <span style="color:#2A2B30;font-family:Arial;font-size:13px;"><strong>Not a member? <a href="./../register/index.php" class="Bold_Grey">Register</a></strong></span></div> </form> </div> <div id="wb_Extension1" style="position:absolute;left:0px;top:0px;width:100px;height:100px;z-index:72;"> </div> </div> <div id="Layer2" style="position:fixed;text-align:center;left:0px;top:0px;right:0px;height:56px;z-index:73;" title=""> <div id="Layer2_Container" style="width:994px;position:relative;margin-left:auto;margin-right:auto;text-align:left;"> <div id="wb_Header_Master_Page" style="position:absolute;left:0px;top:0px;width:991px;height:56px;z-index:13;"> <div id="Layer3" style="position:absolute;text-align:right;left:0px;top:0px;width:220px;height:56px;z-index:11;" title=""> <div id="Layer3_Container" style="width:220px;position:relative;margin-left:auto;margin-right:auto;text-align:left;"> <div id="RollOver1" style="position:absolute;overflow:hidden;left:0px;top:5px;width:219px;height:47px;z-index:0"> <a href="./../../index.html" target="_top"> <img class="hover" alt="" src="images/techyoucation_grey.png" style="left:0px;top:0px;width:219px;height:47px;"> <span><img alt="" src="images/full_logo.png" style="left:0px;top:0px;width:219px;height:47px"></span> </a> </div> </div> </div> <div id="header_inc_layer1" style="position:absolute;text-align:right;left:561px;top:0px;width:430px;height:56px;z-index:12;" title=""> <div id="header_inc_layer1_Container" style="width:430px;position:relative;margin-left:auto;margin-right:auto;text-align:left;"> <div id="signup" style="position:absolute;overflow:hidden;left:231px;top:8px;width:86px;height:41px;z-index:2"> <a href="./../register/index.php"> <img class="hover" alt="" src="images/signup-hover.png" style="left:0px;top:0px;width:86px;height:41px;"> <span><img alt="" src="images/signup-off.png" style="left:0px;top:0px;width:86px;height:41px"></span> </a> </div> <div id="wb_login" style="position:absolute;left:329px;top:8px;width:86px;height:41px;z-index:3;"> <a href="./index.php" onclick="ShowObject('login_dialog', 1);return false;"><img src="images/login-small.png" id="login" alt="" border="0" style="width:86px;height:41px;"></a></div> <div id="wb_search_dark_bg" style="position:absolute;left:134px;top:8px;width:86px;height:41px;z-index:4;"> <img src="images/search.png" id="search_dark_bg" alt="" border="0" style="width:86px;height:41px;"></div> <div id="wb_Search-g" style="position:absolute;left:169px;top:8px;width:51px;height:41px;visibility:hidden;z-index:5;"> <img src="images/img0007.gif" id="Search-g" alt="" style="border-width:0;width:51px;height:41px;"></div> <div id="wb_search-w" style="position:absolute;left:17px;top:8px;width:152px;height:41px;visibility:hidden;z-index:6;"> <img src="images/img0008.gif" id="search-w" alt="" style="border-width:0;width:152px;height:41px;"></div> <div id="wb_Search_show" style="position:absolute;left:192px;top:17px;width:22px;height:22px;z-index:7;"> <a href="#" onclick="ShowObjectWithEffect('wb_search-w', 1, 'slideright', 500);ShowObject('wb_Search-g', 1);ShowObjectWithEffect('search_layer', 1, 'slideright', 500);ShowObject('wb_search_click', 1);return false;"><img src="images/icon-search-da7ca298c043e217cdaced7a129fef8f.png" id="Search_show" alt="" border="0" style="width:22px;height:22px;"></a></div> <div id="search_layer" style="position:absolute;text-align:left;visibility:hidden;left:32px;top:7px;width:149px;height:36px;z-index:8;" title=""> <div id="wb_search_box" style="position:absolute;left:0px;top:7px;width:149px;height:27px;z-index:1;"> <form action="" name="search_box_form" id="search_box_form" accept-charset="UTF-8" onsubmit="return searchPage(features)"> <input type="text" id="search_box_keyword" style="position:absolute;left:0px;top:0px;width:149px;height:27px;line-height:27px;;" name="SiteSearch1" value=""> <label id="search_box_label" style="position:absolute;left:0px;top:7px;" for="search_box_keyword">Search this website</label> </form> </div> </div> <div id="wb_search_click" style="position:absolute;left:192px;top:17px;width:21px;height:21px;visibility:hidden;z-index:9;"> <a href="#" onclick="searchPage();return false;"><img src="images/icon-search-da7ca298c043e217cdaced7a129fef8f.png" id="search_click" alt="" border="0" style="width:21px;height:21px;"></a></div> </div> </div> </div> </div> </div> <div id="footer_layer" style="position:absolute;text-align:center;left:0px;top:494px;width:100%;height:258px;z-index:74;" title=""> <div id="footer_layer_Container" style="width:994px;position:relative;margin-left:auto;margin-right:auto;text-align:left;"> <div id="wb_footer_master_page" style="position:absolute;left:0px;top:0px;width:994px;height:257px;z-index:29;"> <div id="Layer" style="position:absolute;text-align:center;left:1px;top:0px;width:99%;height:257px;z-index:28;" title=""> <div id="Layer_Container" style="width:993px;position:relative;margin-left:auto;margin-right:auto;text-align:left;"> <div id="wb_logo-g" style="position:absolute;left:0px;top:12px;width:219px;height:47px;z-index:14;"> <a href="./../../under_construction/index.html"><img src="images/techyoucation%20grey.png" id="logo-g" alt="" border="0" style="width:219px;height:47px;"></a></div> <div id="wb_mission-text" style="position:absolute;left:6px;top:72px;width:250px;height:48px;text-align:justify;z-index:15;"> <span style="color:#808080;font-family:Arial;font-size:13px;">We are on a mission, that mission is to teach everyone with the passion to learn Technology.</span></div> <hr id="devide" style="margin:0;padding:0;position:absolute;left:8px;top:121px;width:222px;height:1px;z-index:16;"> <div id="wb_copyright-text" style="position:absolute;left:6px;top:172px;width:250px;height:48px;text-align:justify;z-index:17;"> <span style="color:#808080;font-family:Arial;font-size:13px;">© Techyoucation 2013 All trademarks and logos are the property of their respective owners!</span></div> <div id="wb_get-in" style="position:absolute;left:751px;top:7px;width:235px;height:32px;z-index:18;text-align:left;"> <span style="color:#000000;font-family:Arial;font-size:13px;"><strong><a href="./../../under_construction/contact_us/index.html" class="Bold_Grey">Get In Touch </a></strong></span><span style="color:#808080;font-family:Arial;font-size:13px;"><strong><a href="./../../under_construction/contact_us/index.html" class="Bold_Grey">→</a></strong></span><span style="color:#000000;font-family:Arial;font-size:13px;"><strong><br><a href="./../../legal/index.php" class="Bold_Grey">Privacy Policy / Terms Of Service</a></strong></span></div> <div id="wb_vision-logo" style="position:absolute;left:318px;top:12px;width:162px;height:60px;z-index:19;"> <a href="http://secure.thevisionworld.com/aff.php?aff=092" target="_top"><img src="images/VisionHelpdeskLogo.png" id="vision-logo" alt="" border="0" style="width:162px;height:60px;"></a></div> <div id="wb_Vision" style="position:absolute;left:286px;top:72px;width:230px;height:64px;text-align:justify;z-index:20;"> <span style="color:#808080;font-family:Arial;font-size:13px;">We would like to thank vision HelpDesk for supporting us with our mission by supplying us with a free copy of their amazing script.</span></div> <div id="wb_Navaldesigns" style="position:absolute;left:286px;top:152px;width:230px;height:48px;text-align:justify;z-index:21;"> <span style="color:#808080;font-family:Arial;font-size:13px;">We would also like to thank George <a href="http://www.dbtechnosystems.com/" class="Top_Nav">(Navaldesign)</a> for helping us with the membership system on this site.</span></div> <div id="FB-Over" style="position:absolute;overflow:hidden;left:38px;top:134px;width:29px;height:29px;z-index:22"> <a href="https://www.facebook.com/techyoucation"> <img class="hover" alt="" src="images/icon-facebook-new-7fd375259239b05ac8f42657988e351f-over.png" style="left:0px;top:0px;width:29px;height:29px;"> <span><img alt="" src="images/icon-facebook-new-7fd375259239b05ac8f42657988e351f.png" style="left:0px;top:0px;width:29px;height:29px"></span> </a> </div> <div id="G-Over" style="position:absolute;overflow:hidden;left:78px;top:134px;width:29px;height:29px;z-index:23"> <a href="https://plus.google.com/b/113434853007695128940/113434853007695128940/posts"> <img class="hover" alt="" src="images/icon-googleplus-f9e3bf613ef1807f53cc7e3c34fb9b1a-over.png" style="left:0px;top:0px;width:29px;height:29px;"> <span><img alt="" src="images/icon-googleplus-f9e3bf613ef1807f53cc7e3c34fb9b1a.png" style="left:0px;top:0px;width:29px;height:29px"></span> </a> </div> <div id="T-Over" style="position:absolute;overflow:hidden;left:118px;top:134px;width:29px;height:29px;z-index:24"> <a href="https://twitter.com/techyoucation"> <img class="hover" alt="" src="images/icon-twitter-new-47502fddb8222a283378a21e5b421c2d-over.png" style="left:0px;top:0px;width:29px;height:29px;"> <span><img alt="" src="images/icon-twitter-new-47502fddb8222a283378a21e5b421c2d.png" style="left:0px;top:0px;width:29px;height:29px"></span> </a> </div> <div id="YT-Over" style="position:absolute;overflow:hidden;left:158px;top:134px;width:29px;height:29px;z-index:25"> <a href="http://www.youtube.com/techyoucation"> <img class="hover" alt="" src="images/icon-youtube-a442f16454bb0a8fe31df4f93b5d8aa2-over.png" style="left:0px;top:0px;width:29px;height:29px;"> <span><img alt="" src="images/icon-youtube-a442f16454bb0a8fe31df4f93b5d8aa2.png" style="left:0px;top:0px;width:29px;height:29px"></span> </a> </div> <!-- Twitter Follow --> <div id="twitter" style="position:absolute;left:587px;top:6px;width:154px;height:47px;z-index:26"> <a href="https://twitter.com/techyoucation" class="twitter-follow-button" data-show-count="false">Follow @techyoucation</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div> <div id="wb_HTML-image" style="position:absolute;left:610px;top:58px;width:99px;height:139px;z-index:27;"> <img src="images/html5_logo_small.png" id="HTML-image" alt="" border="0" style="width:99px;height:139px;"></div> </div> </div> </div> </div> </div> </body> </html> and here is the login code for the forum. <?php //signin.php include 'connect.php'; include 'header.php'; echo '<h3>Sign in</h3><br />'; //first, check if the user is already signed in. If that is the case, there is no need to display this page if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true) { echo 'You are already signed in, you can <a href="signout.php">sign out</a> if you want.'; } else { if($_SERVER['REQUEST_METHOD'] != 'POST') { /*the form hasn't been posted yet, display it note that the action="" will cause the form to post to the same page it is on */ echo '<form method="post" action=""> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password"><br /> <input type="submit" value="Sign in" /> </form>'; } else { /* so, the form has been posted, we'll process the data in three steps: 1. Check the data 2. Let the user refill the wrong fields (if necessary) 3. Varify if the data is correct and return the correct response */ $errors = array(); /* declare the array for later use */ if(!isset($_POST['username'])) { $errors[] = 'The username field must not be empty.'; } if(!isset($_POST['password'])) { $errors[] = 'The password field must not be empty.'; } if(!empty($errors)) /*check for an empty array, if there are errors, they're in this array (note the ! operator)*/ { echo 'Uh-oh.. a couple of fields are not filled in correctly..<br /><br />'; echo '<ul>'; foreach($errors as $key => $value) /* walk through the array so all the errors get displayed */ { echo '<li>' . $value . '</li>'; /* this generates a nice error list */ } echo '</ul>'; } else { //the form has been posted without errors, so save it //notice the use of mysql_real_escape_string, keep everything safe! //also notice the sha1 function which hashes the password $sql = "SELECT id, username, userlevel FROM USERS WHERE username = '" . mysql_real_escape_string($_POST['username']) . "' AND password = '" . sha1($_POST['password']) . "'"; $result = mysql_query($sql); if(!$result) { //something went wrong, display the error echo 'Something went wrong while signing in. Please try again later.'; //echo mysql_error(); //debugging purposes, uncomment when needed } else { //the query was successfully executed, there are 2 possibilities //1. the query returned data, the user can be signed in //2. the query returned an empty result set, the credentials were wrong if(mysql_num_rows($result) == 0) { echo 'You have supplied a wrong user/password combination. Please try again.'; } else { //set the $_SESSION['signed_in'] variable to TRUE $_SESSION['signed_in'] = true; //we also put the id and username values in the $_SESSION, so we can use it at various pages while($row = mysql_fetch_assoc($result)) { $_SESSION['id'] = $row['id']; $_SESSION['username'] = $row['username']; $_SESSION['userlevel'] = $row['userlevel']; } echo 'Welcome, ' . $_SESSION['username'] . '. <br /><a href="index.php">Proceed to the forum overview</a>.'; } } } } } include 'footer.php'; ?> It looks like you many need the header two... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="A short description." /> <meta name="keywords" content="put, keywords, here" /> <title>PHP-MySQL forum</title> <link rel="stylesheet" href="style.css" type="text/css"> </head> <div id="blog"> <div id="header"><a href="http://techyoucation.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Logo','','images/techyoucation grey.png',1)"><img src="images/full logo.png" alt="techyoucation logo" width="219" height="47" id="Logo" /></a></div> <body> <h1><br></h1> <div id="wrapper"> <div id="menu"> <a class="item" href="/forum/index.php">Home</a> - <a class="item" href="/forum/create_topic.php">Create a topic</a> - <a class="item" href="/forum/create_cat.php">Create a category</a> <div id="userbar"> <?php if($_SESSION['signed_in']) { echo 'Hello <b>' . htmlentities($_SESSION['username']) . '</b>. Not you? <a class="item" href="signout.php">Sign out</a>'; } else { echo '<a class="item" href="signin.php">Sign in</a> or <a class="item" href="signup.php">create an account</a>'; } ?> </div> </div> <div id="content"> Thanks in advance Aled
  11. Hi, I am new to php and I am having trouble with a php login code for website I am making. I am getting a response saying "notice undefined variable row" this is what I have thus far: How would I define that row? <?php $db_usr= $_POST["userid"]; $db_pswd= $_POST["password"]; $con=mysql_connect("localhost",$db_user,$db_pass, $db_name); if(! $con) { die('Connection Failed'.mysql_error()); } mysql_select_db("*****",$con); $sql=mysql_query("SELECT * FROM users WHERE userid='name' and password='password'"); $result=mysql_query($sql); { if($row["userid"]==$db_usr && $row["password"]==$db_pswd) echo "Welcome Back $db_usr "; else echo "Sorry $db_usr"; } ?>
  12. Hello all, This is my very first post here and I hope someone could help me out on this as it has been a labour intensive time to try and learn all about this coding. I am trying to learn this coding using PHP and trying to do stuff myself and just through a lot of research.......I have found the holy grail of all XML feeds and this was the one feed that people who look to the main steam rankings for. Ok so I am very excited to share this with you guys and show you what I have done based on how you have educated me so far, please bear with me here: Ok the XML feed (the holy grail) is the GLOBAL USER RANKINGS, there is only one site using it now: www.aoe2stats.com They are doing what I a trying to achieve and I think I am 95% there based on what you guys have taught me through the coding, ok so here it is, I hope I still have peoples attention here. here is the link to the XML FEED: http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1 Ok, this information I am trying to extract is the following: http://steamcommunity.com/stats/Ageo...l=1&start=5001 ]]> </nextRequestURL> <resultCount>5000</resultCount> <entries> <entry> <steamid>76561198032048763</steamid> <score>689</score> <rank>1</rank> <ugcid>-1</ugcid> <details> <![CDATA[ ]]> </details> </entry> <entry> <steamid>76561198011427258</steamid> <score>632</score> <rank>2</rank> <ugcid>-1</ugcid> <details> <![CDATA[ ]]> ___________________________________________________ Into a table with 4 columns, with the names on each column: Steam Name - Score - Rank - Ugcid Now this is where I am learning also, I need to parse the (steamid) into the (community id) the steam id is the long number above and the community id is username on steam: website to show example: steamidfinder.com ok I have found a script to parse the <steamid>76561198032048763</steamid> into the person name: Huehnerbein as an example above, so I have been doing a lot of reaearching and I have found the following: _____________________________________________________________ Assuming that your input steam_id is $INPUT and your final output array is stored in $OUTPUT, this is the functional for each approach that you could use to convert steam_id to personaname: /** * Convert steam_id to personaname * @returns STRING The name associated with the given steam_id * BOOL FALSE if no match was found */ function steamID_to_name($INPUT, $OUTPUT) { // This gets the relevant part of the API response. $array = $OUTPUT['response']['players']; // Using your function to convert `steam_id` to a community ID $community_id = SteamID2CommunityID($INPUT); // Linear search foreach ($array as $array_item) { // If a match was found... if ($community_id == $array_item['steamid']) // Return the name return $array_item['personaname']; } // If no match was found, return FALSE. return false; } _________________________________________________________________ So the conclusion is the script below, unfortunately is does not work but I have tried to change the neccesary parameters in the script, so the objective is: as what www.aoe2stats.com are the only ones who have done it!! To have the 4 entries in a 4 column table: Steam Name - Score - Rank - Ugcid and to have the steamid parse into the community_id or username. OK THE ACTUAL SCRIPT I HAVE MODIFIED, IT DOES NOT WORK BUT CAN YOU GUYS SHARE WITH ME WHAT MISTAKES I HAVE MADE SO I CAN GET THIS HOLY GRAIL SCRIPT WORKING, I HAVE SPENT HOURS ON THIS: SCRIPT BELOW: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); $sFeed = 'http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1' . microtime(true); /** * Convert steam_id to personaname * @returns STRING The name associated with the given steam_id * BOOL FALSE if no match was found */ function steamID_to_name($INPUT, $OUTPUT) { // This gets the relevant part of the API response. $array = $OUTPUT['response']['players']; // Using your function to convert `steam_id` to a community ID $community_id = SteamID2CommunityID($INPUT); // Linear search foreach ($array as $array_item) { // If a match was found... if ($community_id == $array_item['steamid']) // Return the name return $array_item['personaname']; } // If no match was found, return FALSE. return false; } $dom = new DOMDocument('1.0', 'utf-8'); $dom->load($sFeed); $steamid = $dom->getElementsByTagName('steamid'); if ($entry->length > 0) $score = $dom->getElementsByTagName('score'); if ($entry->length > 0) $rank = $dom->getElementsByTagName('rank'); if ($entry->length > 0) $ugcid = $dom->getElementsByTagName('ugcid'); if ($entry->length > 0) { ?> <style> table, td, th body { font-family:Verdana, Arial, Helvetica; font-size: 81%; margin: 0px; color: #5c3d0b; font-weight:bold; } { border:1px solid black; } th { background-color:e6cb9c; } </style> <table border="1"> <tr> <th>NAME</th> <th>SCORE</th> <th>RANK</th> <th>UGCID</th> </tr> <? foreach ($entry AS $entry) { $steamid = $entry->getElementsByTagName('steamid')->item(0)->nodeValue; $score = $entry->getElementsByTagName('score')->item(0)->nodeValue; $rank = $entry->getElementsByTagName('rank')->item(0)->nodeValue; $ugcid = $entry->getElementsByTagName('ugcid')->item(0)->nodeValue; printf("<tr><td>%s</td><td>%s</td></tr>" . PHP_EOL, $name, $percent); } print('</table>'); } ___________________________________________________________________ OK PLEASE PLEASE GUYS WOULD LOVE TO SEE WHAT I HAVE DONE WRONG TO GET THIS SCRIPT WORKING SO MANY THANKS!!
  13. Hi all, I need a code that downloads all PDF files of a URL (e.g. www.myurl.com)? I want to run this code on my localhost (WAMP). Thank You for you time.
  14. I've always found the task difficult. I use includes and functions wherever I can, but sometimes it seems impossible. Take this code for example: <div> <?php $gotContents = printContents($linkDB, 'home'); foreach($gotContents as $k){ echo "<div class = \"catContents\">"; echo "<div class = \"contentTitle\">".contentTitle($linkDB, $k)[0]."</div>"; echo cutContent($k); echo "</div>"; } ?> </div> Here, there's no way (that I can see) to separate the HTML from the PHP; I can't divide the code into different files since I need parts of it to be encased in DIVs. So, is this type of code acceptable, or is there a better way to handle it? If so, how? Thanks in advance for any replies. EDIT: Also, I'm not interested in using any third-party software/add-on- just raw PHP and HTML please.
  15. Hello, I am working on a personal project which is to generate a set of unique codes and store them in a database. The concept of the project is for me to be able to determine the numbers of codes I want to generate and insert each of them into the database. I have been able to come up with something with the help of a tutorial which is working but not inputting into database and it allows one generation at a time. Please see my code below $username = "root"; $password = "password"; $hostname = "localhost"; $database = "gencode"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db($database,$dbhandle) or die("Could not select $database"); $unique_ref_length = 11; $unique_ref_found = false; $possible_chars = "23456789ABCDFGHJKLMNPQRSTWXYZ"; while (!$unique_ref_found) { $unique_ref = ""; $i = 0; while ($i < $unique_ref_length) { $char = substr($possible_chars, mt_rand(0, strlen($possible_chars)-1), 1); $unique_ref .= $char; $i++; } $query = "SELECT `order_ref_no` FROM `orders` WHERE `order_ref_no`='".$unique_ref."'"; $result = mysql_query($query) or die(mysql_error().' '.$query); if (mysql_num_rows($result)==0) { $unique_ref_found = true; } } echo 'Our unique reference number is: '.$unique_ref; Your assistance will be greatly appreciated.
  16. Hello I am new to this forum, so I am not sure if I have done this write by starting a new topic, if I was not supposed to start a new topic apologies in advance. Basically I want to get a price from a website and update my database with that value in the correct field. So far I have managed to get the price and update the database. However the price is stored as boolean format so when I output the variable it says "0" or "1" and when the database is updated it says "0" or "1". Here is my working code so far. I have tried using intval, doubleval and data type castings but obviously they equal the boolean value. $url = 'a website goes here'; $html = file_get_contents($url); $search = '/<span class="price">(.*?)<\/span>/'; preg_match_all($search, $html, $matches); $price = array_shift($matches[0]); $price1 = str_replace("£","",$price); $price2 = str_replace(',','', $price1); $price3 = str_replace(".","",$price2); print_r($price3); MySQL query is okay as it is. It would be great if you could help me with this code, thanks in advance.
  17. I've begged people all over the web for help with this problem. It's hard to explain because people read about it, and they think I just don't know how to execute simple navigation on WordPress. Let me try to explain: I have a website run by WordPress. I need to edit the home page. When I click Pages-->All Pages-->Home which is linked to home, it's empty. When I go to Apperence-->Editor-->Front Page Page Template it gives me PHP code to dictate basic template stuff, it won't let me edit As you can see from the site, I have things other than the featured items and so on, like the "Bridgett Provenzano" letter at the bottom. But on my supposed home page there is nothing, on my specific theme settings, I have the featured items written out and I have the PHP code for the temlpate but none of that lets me edit the stuff on the front that I need to edit, namley the stuff under the featured items. I hired someone but I don't have any money in the budget to do that again. He somehow added some text into the front page even though I see no way to do so, and cant see where he added it when I look at the code. I'm at a loss. I'm going nuts here trying to figure this out. I don't know PHP, it looks as confusing as hell.
  18. <?php session_start(); $per_page = 10; $query = mysql_query("SELECT * FROM 'bio'"); echo $pages = mysql_result($pages_query, 0); if ($_SESSION ['username']) echo "<right>Welcome, ".$_SESSION['username']."!<br><a href='logout.php'>Log out</a><br><a href='bio.php'>Post an Ad!</a></right>"; else die("You must be logged in!"); $connect = mysql_connect("localhost","root","4shizzle"); //connect to server mysql_select_db("textbooks"); //query the database $query = mysql_query("SELECT * FROM bio"); echo "<table border=1 cellpadding=10> <tr> <th>Date</th> <th>Class</th> <th>Book</th> <th>Price</th> <th>Email</th> </tr>"; while($rows = mysql_fetch_array($query)): $class = $rows['class']; $title = $rows['title']; $email = $rows['email']; $price = $rows['price']; $date = $rows['date']; $newDate = date("M-d", strtotime($date)); echo "<tr>"; echo "<td>" . $newDate . "</td>"; echo "<td>" . $class . "</td>"; echo "<td>" . $title . "</td>"; echo "<td>" . $price . "</td>"; echo "<td>". $email . "</td>"; echo "</tr>"; endwhile; ?>
  19. The code below works great. It pulls data from a MySQL database & displays it in a form. The DB consist of a table named clerk_names & the fields are clerk_id, names, and active. There will always be only 10 entries in this DB. The code below pulls the name & marks the active field from a 1 to a 0 for the particular random name it pulls. Like I said this code works great except I need to add an IF or ELSE or ELSEIF statement so if all the active fields are set to 0, it will mark all 10 of them back to a 1. Basically, once the 10 active field is marked to a 0 with the code below I just need something to mark all of them back to a 1 in the active field.........is this possible? <?php $mysqli = new mysqli('localhost', 'uname', 'password', 'flow'); $sql = "SELECT names, active, clerk_id FROM clerk_names WHERE active = '1' ORDER BY RAND() LIMIT 1"; $res = $mysqli->query($sql); $row = $res->fetch_row(); $randomName = $row[0]; $res->free(); $sql = "UPDATE clerk_names SET active = 0 WHERE clerk_id = " . $row[2] . " " ; $res = $mysqli->query($sql); } mysql_close(); // Close the database connection. ?>
  20. Hi, I'm trying to get my first lines in PHP. I have read some tutorials, but since I'm not a programer is a little hard for me to get it straight. Could someone help me out to put the following javascript into php so I could just call php from my HTML, something like MySelect and get the selector. <h3><font color="#3EA99F">Categories</font></h3> <select id="mySelect" onchange="if(this.options[this.selectedIndex].value != ''){window.top.location.href=this.options[this.selectedIndex].value}"> <option>Select an option</option> <option value="site1">Orange</option> <option value="site2">Pineapple</option> <option value="site3">Banana</option> </select> Thank you so much More Explanation: I want to have something like MyFile.php where I have definied the Selector, so I can call MySelect from Index.html and write the select in the html, so If I have 400 .html pages, I do not have to change the code in the 400 pages if I want to add a value or make any change, but just made the change in MyFile.php.
  21. Dear all, I have some problem with my php code i try to make some XML and PHP Content managmant system, but i have now some problem with the root? He give the next error: Fatal error: Call to a member function root() on a non-object in /home/......./public_html/searchArticles.php on line 29 See here my code please: <?php session_start(); $results = array(); //this is a very simple, potentially very slow search function extractText($array){ if(count($array) <= 1){ //we only have one tag to process! for ($i = 0; $i<count($array); $i++){ $node = $array[$i]; $value = $node->get_content(); } return $value; } } $dh = opendir('./xml/'); while ($file = readdir($dh)){ if (eregi("^\\.\\.?$", $file)) { continue; } $open = "./xml/".$file; $xml = "domxml_open_file" .$open; //we need to pull out all the things from this file that we will need to //build our links $root = $xml->root("id"); $id = $root->get_attribute("id"); $stat_array = $root->get_elements_by_tagname("status"); $status = extractText($stat_array); $k_array = $root->get_elements_by_tagname("keywords"); $keywords = extractText($k_array); $h_array = $root->get_elements_by_tagname("headline"); $headline = extractText($h_array); $ab_array = $root->get_elements_by_tagname("abstract"); $abstract = extractText($ab_array); if ($status != "live"){ continue; } if (eregi($searchTerm, $keywords) or eregi($searchTerm,$headline)){ $list['abstract'] = $abstract; $list['headline'] = $headline; $list['file'] = $file; $results[] = $list; } } $results = array_unique($results); ?> <h1>Search Results</h1> <a href="index.php">back to main</a> <p>You searched for: <i><?php echo $searchTerm ?></i></p> <hr> <?php if (count($results)>0){ echo "<p>Your search results:</p>"; foreach ($results as $key => $listing){ echo "<br><a href=\"showArticle.php?file=".$listing["file"]."\">" . $listing["headline"]."</a>\n"; echo "<br>". $listing["abstract"]; echo "<br>"; } } else { echo "<p>Sorry, no articles matched your search term.</p>"; } ?> I hope for some sugestions, Thanks a lot!
  22. I have this code <script type="text/javascript"> $(document).ready(function() { // I added the video size here in case you wanted to modify it more easily var vidWidth = 300; // 425; var vidHeight = 200; // 344; var obj = '<object width="' + vidWidth + '" height="' + vidHeight + '">' + '<param name="movie" value="http://www.youtube.com/v/[vid]&hl=en&fs=1">' + '</param><param name="allowFullScreen" value="true"></param><param ' + 'name="allowscriptaccess" value="always"></param><em' + 'bed src="http://www.youtube.com/v/[vid]&hl=en&fs=1" ' + 'type="application/x-shockwave-flash" allowscriptaccess="always" ' + 'allowfullscreen="true" width="' + vidWidth + '" ' + 'height="' + vidHeight + '"></embed></object> '; $('.posthold:contains("youtube.com/watch")').each(function() { var that = $(this); var vid = that.html().match(/v=([\w\-]+)/g); // end up with v=oHg5SJYRHA0 that.html(function(i, h) { return h.replace(/(http:\/\/www.youtube.com\/watch\?v=+\S+\S?)/g, ''); }); if (vid.length) { $.each(vid, function(i) { that.append(obj.replace(/\[vid\]/g, this.replace('v=', ''))); }); } }); }); </script> It works great at embeding videos from url's. But I have a small problem with it that I have been trying to solve but i keep breaking the code. Basically I have the following div setup <div class="grid_10 alpha omega posthold" > <div class="clearfix"> <div class="grid_2 alpha"> <img src="/images/no-image/logo_default.jpg" width="100" height="100" /> </a></div> <div class="grid_8 omega"> <h1>Some Name Here</h1> <p>Some Comment here</p> </div> </div> </div> Im trying to get the video to appear directly after the closing paragraph tag where it says some comment here. The user enters the video as part of a post. I store the post in a database and when I pull the post out I swap the url from youtube to the embed code. This is a repeating div so there maybe many instances that a video appears. Is this even possible. At the minute the video appears after the last closing div tag.
  23. Dear all, Can somebody tell me what the problem is from this results! And my result if i want it load in my browser: Just look here!! Maby is it a stupid ask but i sitting on this moment stuck.. Thanks!
  24. heres my code: $sql=" INSERT INTO `a8392424_pets`.`users` ( `user_id` , `user_name` , `user_pass` , `user_email` , `user_date` , `user_level` , `posts` , `married` , `cash` , `tokens` ) VALUES ( NULL, '" . mysql_real_escape_string($_POST['user_name']) . "', '" . sha1($_POST['user_pass']) . "', '" . mysql_real_escape_string($_POST['user_email']) . "', NOW(),'0', 'noone', '10000', '10')"; $result = mysql_query($sql); if(!$result) { //something went wrong, display the error echo 'Something went wrong while registering. Please try again later.'; //echo mysql_error(); //debugging purposes, uncomment when needed } When I execute it, using my signup form, the query fails. my connection to database is GOOD.
  25. Hi there, Basically what i need is for my site to not refresh every time i click one of the buttons. I have got as far as finding out that it requires AJAX but i don’t have a clue how to use it This is some of my code...it basically covers the main parts but if you need more then please ask... <html> <head> <script> $(function() { var tabs = $( "#tabs" ).tabs({collapsible: true, active:"flase"}); tabs.find( ".ui-tabs-nav" ).sortable({axis:"x", stop:function() {tabs.tabs( "refresh" );} }); }); $(function() { $( ".box" ).draggable({containment: "#restrictor", scroll: false, snap: true, opacity: 0.35, cancel: ".box-content" }); $( ".box" ).addClass( "ui-widget ui-widget-content ui-corner-all" ) .find( ".box-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "<span class='ui-icon ui-icon-minusthick'></span>") .end() .find( ".box-content" ); $( ".box-header .ui-icon" ).click(function() { $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" ); $( this ).parents( ".box:first" ).find( ".box-content" ).toggle(); }); $( "#container" ).disableSelection(); }); $(function() { $( "input[type=submit], #Buttons, button" ) .button() .click(function( event ) { event.preventDefault(); }); }); setInterval(function() { $('#timeval').load('Home_Automation/Includes/time.php'); }, 1000); </script> </head> <body> <!------------------------Serial Port/Commands/Functions---------------------------> <?php if (isset($_GET['action'])) { require("Home_Automation/Includes/php_serial.class.php"); $serial = new phpSerial(); $serial->deviceSet("COM3"); exec('mode COM3 BAUD=96 PARITY=n DATA=8 STOP=1 xon=off octs=off rts=on'); $serial->deviceOpen(); if ($_GET['action'] == "on") { $serial->sendMessage("L"); $file = fopen("Home_Automation/Includes/lights.txt","w"); fwrite($file, "1"); fclose($file); } else if ($_GET['action'] == "off") { $serial->sendMessage("l"); $file = fopen("Home_Automation/Includes/lights.txt","w"); fwrite($file, "0"); fclose($file); } else if ($_GET['action'] == "unlock") { $serial->sendMessage("D"); $file = fopen("Home_Automation/Includes/doors.txt","w"); fwrite($file, "1"); fclose($file); } $serial->deviceClose(); } ?> <!--------------------------------Main Container-----------------------------------> <div id="restrictor" class="ui-widget-content"> <!--------------------------------Controll Switches--------------------------------> <!-------------------------------------Doors---------------------------------------> <div class="box"> <div class="box-header">Doors</div> <div class="box-content"> <a class="button" href="<?php echo $_SERVER['PHP_SELF'] . '?action=unlock' ?>">Unlock</a> <div id="PHP"> <?php $file = fopen("Home_Automation/Includes/doors.txt", "r") or exit("Unable to open file!"); if (fgetc($file)==1) echo "<img src=\"Home_Automation/Images/Door_Open.gif\" />"; else echo "<img src=\"Home_Automation/Images/Door_Closed.gif\" />"; fclose($file); ?> </div> <a class="button" href="<?php echo $_SERVER['PHP_SELF'] . '?action=lock' ?>">Lock</a> </div></div> </div> </html> It’s not really in order as i cut bits out but that covers the basic code... If someone could please show me some code snippets that i would need to include or something that would be great Thanks, Chris
×
×
  • 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.