Jump to content

Search the Community

Showing results for tags 'coding'.

  • 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. I'm messing around with unconventional coding practices, just to .... practice. The following code isn't being used for any amazing projects or anything, it's just me messing around with things getting practice. It's a simple code but it keeps telling me the constants are undefined. //defining the variables through an array $db['db_host'] = "localhost"; $db['db_user'] = "root"; $db['db_pass'] = ""; $db['db_name'] = "cms"; //fancy way of making them constants foreach($db as $key => $value) { define(strtoupper($key), $value); } $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if($conn) { echo "We are connected"; } Simple, simple, very simple but can someone tell me why it's not creating the constants? All of them in $conn are coming back as undefined.
  2. i want to display 'Welcome userid!' after user has successfully logged in. I managed to display it after successfully logged in, but when the user key in the wrong userid and password, the 'Welcome userid' is also displayed. What should i do about it? Below are my coding: login.html processLogin.php index.html
  3. $subtotal = $row[0]; $delivery = $row[1]; $discount = $row[2]; $vatrate = $row[3]; $totalex = str_replace(",","",$subtotal) + str_replace(",","",$delivery); $vatamount = ($totalex - $discount) * ($vatrate/100); $vatamount = number_format($vatamount, 2, '.', ','); $total = $row[4]; $centinel_total = $total * 100; $centinel_delivery = $delivery * 100; $centinel_vatamount = $vatamount * 100; I've got a custom written cart system which for some reason is not passing the correct amounts to our 3D secure processor (Cardinel commerce). I'm not a programmer but looking at how it seems to work I think the issue is with this code. From the processor logs we are passing the tax value with a negative amount and the total is always £1 when the total is above £1000. It all works fine as it should if the total amount is LESS than £1000! Anyone got any ideas what's going on? I'm more than happy to pay someone to fix this!!
  4. I was wondering if it's possible to retain loaded files and the current error setttings after a header("Location: xxxx.php") is issued, for example in this: // Start up the session - not used yet but there just in case session_start(1); // Enable the Autoloader and initialise it require_once 'Autoloader.php'; Autoloader::init(); // Check if the application has been installed yet ---------------------------- if(!file_exists('Engine/config.php')){ session_write_close(); header("Location: install/index.php"); die(); } And I get a class not found error when I open the install/index.php session_start(1); // @todo: Disable this in the production version .... I already did this in the main index -- do I have to do this on all pages that may error? error_reporting(E_ALL & ~E_STRICT); ini_set("display_errors",1); // Because we jumped here, we have to reinstall the autoloader -- why? require_once '../Autoloader.php'; Autoloader::init(); While I can understand I wouldn't want this if I was firing off to a completely different site, is there anyway to retain the settings within the same server environment or do I have to reset everything as above. I even tried using session in the hope that this would 'remember' but it didn't work.
  5. database.php ________________________________________________________________________________________ $res = pg_query ($conn, "SELECT artist, composer, genre, title, album, label, price, description FROM music"); echo "<table border='1'>"; while($a = pg_fetch_array($res)){ echo "<td>" . $a['1'] . "</td>"; echo "<td>" . $a['2'] . "</td>"; echo "<td>" . $a['3'] . "</td>"; echo "<td>" . $a['4'] . "</td>"; echo "<td>" . $a['5'] . "</td>"; echo "<td>" . $a['6'] . "</td>"; echo "<td>" . $a['7'] . "</td>"; echo '<td><input type="checkbox" name="music[]" value="$ref"' . $row['0'] . $row['1'] . $row['2'] . $row['3'] . $row['4'] . $row['5'] . $row['6'] . $row['7'] . '"/></td>'; echo"</tr>"; } echo "</table>\n"; ?> _____________________________________________________________________________- shoppingbasket.php _____________________________________________________________________________- <form action="shoppingbasket.php" method="POST"> Send To Basket: <name="music"> <input type="submit" value="submit"> </form> cant get it to send data from database to this page shoppingbasket.php if(isset($_POST['music'])){ if (is_array($_POST['music'])) { foreach($_POST['music'] as $row){ echo $row; } } else { $row = $_POST['music']; echo $row; } }
  6. Notice: Undefined index: category in C:\xampp\htdocs\content\cron\check_deposits.php on line 18 Notice: Undefined index: confirmations in C:\xampp\htdocs\content\cron\check_deposits.php on line 19 Notice: Undefined index: address in C:\xampp\htdocs\content\cron\check_deposits.php on line 20 Notice: Undefined index: amount in C:\xampp\htdocs\content\cron\check_deposits.php on line 21 Notice: Undefined index: txid in C:\xampp\htdocs\content\cron\check_deposits.php on line 22 <?php // CRON must be running every minute! $included=true; include '../../inc/db-conf.php'; include '../../inc/wallet_driver.php'; $wallet=new jsonRPCClient($driver_login); include '../../inc/functions.php'; $deposits=mysql_query("SELECT * FROM `deposits`"); while ($dp=mysql_fetch_array($deposits)) { $received=0; $txid=''; $txs=$wallet->listtransactions('',2000); $txs=array_reverse($txs); foreach ($txs as $tx) { if ($tx['category']!='receive') continue; if ($tx['confirmations']<1) continue; if ($tx['address']!=$dp['address']) continue; $received=$tx['amount']; $txid=$tx['txid']; break; } if ($received<0.00000001) continue; $txid=($txid=='')?'[unknown]':$txid; if ($dp['received']==1) { mysql_query("UPDATE `deposits` SET `confirmations`=`confirmations`+1 WHERE `id`=$dp[id] LIMIT 1"); if (++$dp['confirmations']>=6) { $delExed=false; do { $delExed=mysql_query("DELETE FROM `deposits` WHERE `id`=$dp[id] LIMIT 1"); } while ($delExed==false); mysql_query("UPDATE `players` SET `balance`=TRUNCATE(ROUND((`balance`+$received),9), WHERE `id`=$dp[player_id] LIMIT 1"); mysql_query("INSERT INTO `transactions` (`player_id`,`amount`,`txid`) VALUES ($dp[player_id],$dp[amount],'$dp[txid]')"); } continue; } mysql_query("UPDATE `deposits` SET `received`=1,`amount`=$received,`txid`='$txid' WHERE `id`=$dp[id] LIMIT 1"); } mysql_query("DELETE FROM `deposits` WHERE `time_generated`<NOW()-INTERVAL 7 DAY"); ?> For some reason I am getting all these errors, and I cannot figure out why? Is there anyone out there that thinks they know what is wrong with it? check_deposits.php
  7. Hi everyone, I'm hoping the someone can guide me in the right direction for what I need to do. Does anyone know of a really good tutorial and/or information about a plugin product that is available to do what I need? For example, what I need is to create a website that has the ability to allow video conferencing between a teacher and students. This what I envision - a college professor can log on to his website and display a live video feed of him. Also, as each of his students log on, their live video feed is then also supplied. Would prefer a already made plugin product but would also like to look at raw code in PHP to see how something like this could be accomplished. Thank you in advance. Charles
  8. I have 100 Active Facebook access tokens. For each account I have more than one access token. I want to keep only one token for each account and want to delete the others. And i don't want to do this manually so please post a PHP script which check all the tokens and keep only one active token for each account. These tokens are present in a folder named "tok3ns".
  9. This is my first time posting sorry if anything is wrong. attached are my files in question but i don't know what is wrong. I want to show info from a .txt file or something similar within the website I'm working on. In AS3 it was easy to read and use an xml file but within html/php i cant remember. i want to be able to have to have the people im making the site for to be able to just update the text file and it will update the certain part of the site with the new information. Currently for some reason its commenting out part of my php code that i believe should read and echo the lines of the text file. this is the php code: <div id="home"> <h3>Updates From the Staff</h3> <p> <?php $file = fopen("news.txt", "r") or exit("Unable to open file!"); while(!feof($file)) { echo fgets($file). "<br>"; } fclose($file); ?> </p> </div><!-- End Nav Home --> this is what shows when i inspect element with chrome: <!--?php $file = fopen("news.txt", "r") or exit("Unable to open file!"); //Output a line of the file until the end is reached while(!feof($file)) { echo fgets($file). "<br--> its commenting out everything till the line brake and just showing "; } fclose($file); If someone could help me that would be amazing if not thats ok aswell.
  10. What I am aiming to do, with some help as I am new to PHP.. Is that I want to create a shortcode for this plug in so that I can use the shortcode in a selected footer area or post. Thanks for your time in advanced.. really need help. This is the plugin's only file. <?php /* Plugin Name: Constant Contact Widget Plugin URI: Description: Constant Contant widget for submitting email address Version: 1.5 Author: Author URI: License: GPL2 */ /* 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 */ if (class_exists('WP_Widget')) add_action('widgets_init','sf_constantcontact_widget'); if (is_admin()) { add_action('wp_ajax_nopriv_constantcontactadd','sf_constantcontact_ajax'); add_action('wp_ajax_constantcontactadd','sf_constantcontact_ajax'); add_action('admin_menu','sf_constantcontact_menu'); add_action('admin_init','sf_constantcontact_admin'); } function sf_constantcontact_ajax() { ob_clean(); $set=get_option('sf_mcc'); if (empty($set['log'])||empty($set['pwd'])) echo __('Plugin settings incomplete'); else if (empty($_POST['grp'])) echo __('No contact list specified'); else if (empty($_POST['eml'])) echo __('No email provided'); else { $rsp=wp_remote_get("http://ccprod.roving.com/roving/wdk/API_AddSiteVisitor.jsp?" .'loginName='.urlencode($set['log']) .'&loginPassword='.urlencode($set['pwd']) .'&ea='.urlencode($_POST['eml']) .'&ic='.urlencode($_POST['grp']) .(empty($_POST['fnm'])?'':('&First_Name='.urlencode(strip_tags($_POST['fnm'])))) .(empty($_POST['lnm'])?'':('&Last_Name='.urlencode(strip_tags($_POST['lnm']))))); if (is_wp_error($rsp)) echo __('Could not connect to Constant Contact'); else { $rsp=explode("\n",$rsp['body']); if (intval($rsp[0])) echo count($rsp)>1?$rsp[1]:(intval($rsp[0])==400?__('Constant Contact username/password not accepted'):__('Constant Contact error')); } } die(); } function sf_constantcontact_widget() { register_widget('sf_widget_constantcontact'); } function sf_constantcontact_admin() { register_setting('sf_constantcontact_group','sf_mcc','sf_constantcontact_validate'); } function sf_constantcontact_menu() { add_options_page('Constant Contact Settings','Constant Contact','manage_options','sf_constantcontact_options','sf_constantcontact_options'); } function sf_constantcontact_options() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } echo '<div class="wrap"><h2>Constant Contact Settings</h2>' .'<form action="options.php" method="post">'; settings_fields("sf_constantcontact_group"); $set=get_option('sf_mcc'); echo '<table class="form-table">' .'<tr valign="top"><th scope="row">Constant Contact Username</th><td><input type="text" name="sf_mcc[log]" value="'.(isset($set['log'])?$set['log']:'').'" /></td></tr>' .'<tr valign="top"><th scope="row">Constant Contact Password</th><td><input type="password" name="sf_mcc[pwd]" value="'.(isset($set['pwd'])?$set['pwd']:'').'" /></td></tr>' .'</table>' .'<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save"></p>' .'</form></div>'; } function sf_constantcontact_validate($in) { $in['log']=trim($in['log']); $in['pwd']=trim($in['pwd']); return $in; } if (class_exists('WP_Widget')) { class sf_widget_constantcontact extends WP_Widget { public function __construct() { parent::__construct('sf_widget_constantcontact','Constant Contact',array('description'=>'Email subscription widget')); } public function widget($args,$instance) { extract($args); $id=str_replace('-','_',$this->id); $title=apply_filters('widget_title',$instance['title']); if (empty($title)) echo str_replace('widget_sf_widget_constantcontact','widget_sf_widget_constantcontact widget_no_title',$before_widget); else echo $before_widget; if (!empty($title)) echo $before_title.$title.$after_title; echo '<div id="'.$id.'_form">' .(empty($instance['txt'])?'':('<p>'.$instance['txt'].'</p>')) .'<input type="hidden" name="grp" value="'.esc_attr($instance['grp']).'" />' .(empty($instance['nam']) ?('<input type="text" name="eml" class="input" placeholder="'.__('Email').'" />') :('<label for="fnm">'.__('First Name').'</label><input type="text" name="fnm" class="input" />' .'<label for="lnm">'.__('Last Name').'</label><input type="text" name="lnm" class="input" />' .'<label for="eml">'.__('Email').'</label><input type="text" name="eml" class="input" />')) .'<input type="submit" value="'.esc_attr($instance['btn']).'" onclick="'.$id.'_submit(this.parentNode)" />' .'</div>' .'<script>function '.$id.'_submit(n){' .'for(var i=n.firstChild,eml=false,val=["action=constantcontactadd"];i;i=i.nextSibling)if(!(i.nodeName!="INPUT"||!i.name)){if(!(i.name!="eml"||!i.value)) eml=true;val.push(i.name+"="+encodeURIComponent(i.value));}' .'if(!eml){alert("'.__('Please enter an email address').'");return;}' .'var xml=new XMLHttpRequest();' .'xml.open("POST","'.admin_url('admin-ajax.php').'",true);' .'xml.setRequestHeader("Content-type","application/x-www-form-urlencoded");' .'xml.onreadystatechange=function(){if(this.readyState==4){if(this.status==200){if(this.responseText) alert(this.responseText); else '.(preg_match('/^\/\/|^http:\/\/|^https:\/\//i',$instance['msg'])?('setTimeout(\'window.location="'.esc_attr($instance['msg']).'";\',100);'):('n.innerHTML="'.esc_attr($instance['msg']).'";')).'} else alert(this.statusText);}};' .'xml.send(val.join(String.fromCharCode(38)));' .'}</script>'; echo $after_widget; } public function update($new_instance,$old_instance ) { $instance=$old_instance; $instance['title']=strip_tags($new_instance['title']); $instance['txt']=trim($new_instance['txt']); $instance['btn']=trim($new_instance['btn']); $instance['grp']=trim($new_instance['grp']); $instance['msg']=trim($new_instance['msg']); if (!empty($new_instance['nam'])) $instance['nam']=1; else unset($instance['nam']); return $instance; } public function form($instance) { $instance=wp_parse_args($instance,array('title'=>'','txt'=>'','btn'=>'Subscribe','log'=>'','pwd'=>'','grp'=>'General Interest','msg'=>'Thank you, you\'ve been added to the list!','nam'=>'')); echo '<p><label for="'.$this->get_field_id('title').'">Title:</label><input class="widefat" id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" type="text" value="'.esc_attr($instance['title']).'" /></p>' .'<p><label for="'.$this->get_field_id('txt').'">Description:</label><input class="widefat" id="'.$this->get_field_id('txt').'" name="'.$this->get_field_name('txt').'" type="text" value="'.esc_attr($instance['txt']).'" placeholder="description" /></p>' .'<p><label for="'.$this->get_field_id('btn').'">Button Text:</label><input class="widefat" id="'.$this->get_field_id('btn').'" name="'.$this->get_field_name('btn').'" type="text" value="'.esc_attr($instance['btn']).'" placeholder="button text" /></p>' .'<p><label for="'.$this->get_field_id('grp').'">Contact List Name:</label><input class="widefat" id="'.$this->get_field_id('grp').'" name="'.$this->get_field_name('grp').'" type="text" value="'.esc_attr($instance['grp']).'" /></p>' .'<p><label for="'.$this->get_field_id('msg').'">Success Message/URL:</label><input class="widefat" id="'.$this->get_field_id('msg').'" name="'.$this->get_field_name('msg').'" type="text" value="'.esc_attr($instance['msg']).'" /></p>' .'<p><input type="checkbox" id="'.$this->get_field_id('nam').'" name="'.$this->get_field_name('nam').'" value="1"'.(empty($instance['nam'])?'':' checked').'> <label for="'.$this->get_field_id('nam').'">Ask for first and last name</label></p>'; } }} ?>
  11. My code is, <?php // This block allows our program to access the MySQL database. // Stores your login information in PHP variables require_once '223login.php'; // Accesses the login information to connect to the MySQL server using your credentials and database $db_server = mysql_connect($db_hostname, $db_username, $db_password); // This provides the error message that will appear if your credentials or database are invalid if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_select_db($db_database) or die("Unable to select database: " . mysql_error()); // Store the query string from 2.2.3.A Step 17 $query = "SELECT * FROM requests WHERE model_id=1"; // Searches the database returning results that match the query // Results come in a table stored in $requests_for_model $requests_for_model = mysql_query($query); // The mysql_num_rows function returns an integer representation of number of rows for the table passed as an argument $number_of_requests = mysql_num_rows($requests_for_model); for ($current_row = 0; $current_row < $number_of_requests; $current_row++) { // walker variable (through rows in the table) $request = mysql_fetch_row($requests_for_model); // query directed to get a table containing the one row that has a store matching the store ID in the current request $query = "SELECT * FROM store_info WHERE store_id='" . $request[1] . "'"; $store_requesting = mysql_query($query); // A table containing the store $store = mysql_fetch_row($store_requesting); // Get the only row in the table (unique store ID number guarantees this) echo $store[2]; // output the 2nd item in the row for that store, which is the city if ($current_row < $number_of_requests - 1) // Makes sure commas are only printed after results that are not the last { echo ", "; } } ?> I do not know how to fix this. Help much appreciated.
  12. Looking for a coder for a quick project. Should be an hour or two of work for the right person. We have a very basic (already designed) website where we need twitpics with a line of text to appear automatically. Sound like your type of thing? Email me at erin.v.doyle@gmail.com
  13. Hey guys I decided I wanted to learn PHP and MYSQL so I joined lynda.com and watched a tutorial on php & mysql and got pretty bored of it after a couple of videos. Not judging the person teaching it either but it still seems really confusing to me even though I would love to be able to create content managment systems and code my own websites in php. Whilst practicing some of the exercises I taught to myself, "wow there is really so much to remember about different variables,stings and functions"...All those pieces of code would be hard to remember. All seemed a little overwhelming. I would also love to learn how to create my own wordpress blogs from scatch. But correct me if i'm wrong, is it really a long process to learning php. I'm thinking of paying somebody to teach me 1-on-1, afterall it might be the fastest way to learn. I already know html & CSS so wanna take it it to the next level now. Would love to hear how some of you learnt php/mysql and whether or not you took or courses or studied it at college/university. It's all new to me guys but i'm sure once I get the hang of it and practice it everyday I'll learn most of the basics. Do you think W3Schools would be a great place to start? Thanks Guys
  14. I am on the first year at college studying computer science and they sent me to write a php program that can change a decimal number to IEEE754 standard on 16bits. I know most of you will laugh because it is very easy but I need help. this is what i got so far. ALL i need is how to control the mantissa.. you know, save 10 numbers.. and how to control the while loop so he stops when i have 10 spots on mantissa.. <?php echo "Enter any number\n"; $number=trim(fgets(STDIN)); $low=floor($number); $decimal=$number - $low; $real=decbin($low); while(0<$decimal<1) { $mantissa[]=$decimal*2; } echo "\n"; ?>
  15. Hi all, I am looking at the possibility of setting up a coding school for young people in the third world. I am not a coder or programmer at all and would like suggestions as the best way to teach these skills. Do I need a competent teacher or are there reputable comprehensive online courses available. I could certainly provide the IT hardware and connectivity. How do most coders in the USA gain their skills? Are most of them graduates? Lastly, which institutions in the US might provide funding for a project like this? Where could I start looking? This will be a non profit venture. Any help/advice will be gratefully received.
  16. Hi, I'm currently setting up some new code for a website I am working on - It is PHP based, and is accessing a MySQL database. I've been looking at the logs on the server, and it seems everytime someone does a search using the site, it actually runs the query twice - Once using the 'LIMIT' command, and once without. If this is the case, then it is surely wasting resources as it should only be running it once. Can anyone spot where this is going wrong, and offer any assistance and guidance ? Here is the code in question (I don't know if you need all the code): <?php require_once('Connections/databaseconnect.php'); ?> <?php require('functionformat.php'); ?> <?php /* The following strips out the use of the % and _ wildcard characters, before running the query. */ $pattern = array('/%/','/_/','/!/','/$/','/^/','/{/','/}/','/,/','/=/','/"/','/|/','/:/','/;/'); $replace = array('',''); $search_name = preg_replace($pattern, $replace, $_POST[search_name]); $search_name = mysql_real_escape_string($search_name); $unconfirmed_header = 0; $confirmed_header = 0; if (strlen($search_name) < "2") { } else { $maxRows_Recordset1 = 1250; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_stemel, $stemel); $query_Recordset1 = "SELECT company_number, company_name, url, phone_no, mobile_no, home_no, mob2_no, other_info, confirmed FROM contact1 WHERE (confirmed = '0' OR confirmed = '1') AND (company_name LIKE '%$search_name%' OR other_info LIKE '%$search_name%' OR url LIKE '%$search_name%') ORDER BY confirmed DESC, company_name ASC, company_number ASC"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $stemel) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <?php /* This section passes on received values as hidden fields after validating null entries. */ include ('header.php'); ?> <link rel="stylesheet" href="search.css" type="text/css" /> <?php if (($totalRows_Recordset1) > 0) { if ($row_Recordset1['confirmed'] & 1) { ?> <table width="100%" align="center" border="0"> <tr> <td><font size="2"> <div class="seperator"></div> <div class="boardcontainer"> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr><td colspan="6" class="catbg" height="18" >Main Database</td></tr> <tr> <td class="windowbg" width="28%" align="center">Company Name</td> <td class="windowbg" width="12%" align="center">Phone No</td> <td class="windowbg" width="12%" align="center">Mobile No</td> <td class="windowbg" width="12%" align="center">Home No</td> <td class="windowbg" width="12%" align="center">Personal Mobile</td> <td class="windowbg" width="24%" align="center">Other Info</td> </tr> <?php $confirmed_header=1; } /* Message that is displayed when no CONFIRMED numbers are returned from the database */ { if ($confirmed_header < 1) { ?> <table width="100%" align="center" border="0"> <tr> <td><font size="2"> <div class="seperator"></div> <div class="boardcontainer"> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr><td colspan="6" class="catbg" height="18" >Main Database</td></tr> <tr> <td class="windowbg" width="28%" align="center">Company Name</td> <td class="windowbg" width="12%" align="center">Phone No</td> <td class="windowbg" width="12%" align="center">Mobile No</td> <td class="windowbg" width="12%" align="center">Home No</td> <td class="windowbg" width="12%" align="center">Personal Mobile</td> <td class="windowbg" width="24%" align="center">Other Info</td> </tr> <tr> <td class=windowbg2 colspan="6" align=center BGCOLOR=#FFFFCC><B>No confirmed numbers have been found that match the criteria you entered. One or more have been found in the unconfirmed list, and are listed below.</B></td> </tr> </table> </div> <?php }{} } ?> <?php do { ?> <tr> <?php if ($row_Recordset1['confirmed'] & 1) { if (strlen($row_Recordset1['url']) > "2") { echo '<td class=windowbg2 width=28% align=center BGCOLOR=#FFFFCC><a href=http://www.mywebsite.com/external.php?site='.$row_Recordset1['url'].' target="_blank">'.$row_Recordset1 ['company_name'].'</a></td>'; } else { echo '<td class=windowbg2 width=28% align=center BGCOLOR=#FFFFCC>'.$row_Recordset1['company_name'].'</a></td>'; } echo '<td class=windowbg2 width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['phone_no']).'</td>'; echo '<td class=windowbg2 width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['mobile_no']).'</td>'; echo '<td class=windowbg2 width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['home_no']).'</td>'; echo '<td class=windowbg2 width=12% align=center BGCOLOR=#FFFFCC>*'.format_phone($row_Recordset1['mob2_no']).'</td>'; echo '<td class=windowbg2 width=24% align=center BGCOLOR=#FFFFCC>*'.$row_Recordset1['other_info'].'</td></tr>'; } else { if ($unconfirmed_header < 1) { ?> </tr> </table> </div><br /> <table width="100%" align="center" border="0"> <tr><td><font size="2"> <div class="seperator"></div> <div class="boardcontainer"> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr><td colspan="6" class="catbg" height="18" >Unconfirmed Numbers</td></tr> <tr> <td class="windowbg" width="28%" align="center">Company Name</td> <td class="windowbg" width="12%" align="center">Phone No</td> <td class="windowbg" width="12%" align="center">Mobile No</td> <td class="windowbg" width="12%" align="center">Home No</td> <td class="windowbg" width="12%" align="center">Personal Mobile</td> <td class="windowbg" width="24%" align="center">Other Info</td> </tr> <?php $unconfirmed_header = 1; } if (strlen($row_Recordset1['url']) > "2") { echo '<td class=windowuv width=28% align=center BGCOLOR=#CCFFFF> '.$row_Recordset1['company_name'].'</td>'; } else { echo '<td class=windowuv width=28% align=center BGCOLOR=#CCFFFF>'.$row_Recordset1['company_name'].'</a></td>'; } echo '<td class=windowuv width=12% align=center BGCOLOR=#CCFFFF>*'.format_phone($row_Recordset1['phone_no']).'</td>'; echo '<td class=windowuv width=12% align=center BGCOLOR=#CCFFFF>*'.format_phone($row_Recordset1['mobile_no']).'</td>'; echo '<td class=windowuv width=12% align=center BGCOLOR=#CCFFFF>*'.format_phone($row_Recordset1['home_no']).'</td>'; echo '<td class=windowuv width=12% align=center BGCOLOR=#CCFFFF>*'.format_phone($row_Recordset1['mob2_no']).'</td>'; echo '<td class=windowuv width=24% align=center BGCOLOR=#CCFFFF>*'.$row_Recordset1['other_info'].'</td></tr>'; } ?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </tr> </table> </div><br /> <div class="seperator"> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td class="titlebg" align="center" colspan="2"> Info Centre </td> </tr> <td class="windowbg2"> <div style="float: left; width: 59%; text-align: left;"> <span class="small">Please update us with any corrections as soon as possible.</span><br /> </div> <div style="float: left; width: 40%; text-align: left;"> <div class="small" style="float: left; width: 49%;"><span style="color: red;"><b>lllll</b></span></div> </div> </td> </tr> </table> </div> </font></td> </tr> </table> <?php } else { ?> <body bgcolor="#FFFFCC"> <tr><td colspan=10> <center><table border=1 bordercolor=navy cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCCFF"><div class=TableTitle> <p align="center"><b><font face="Tahoma">NO RESULTS FOUND</font></b></div></td></tr><tr><td BGCOLOR=#FFFFCC> <div align="center"> <h3> </h3> </div> <div align="center"> <h3><font face="Tahoma" size="3">Your search didn't match any records.</B></font></h3> <h3> </h3> </div> </td></tr></table></center> </td></tr></table><br> <?php } ?> <br> <?php require ('footer.php'); if (($totalRows_Recordset1) > 0) { mysql_free_result($Recordset1); mysql_close(); }else{ } ?> Thanks in advance for any help, Daniel
  17. Could anyone explain why my script just isnt working? I dont understand PHP and would be enterally greatful. Im told Parse error: syntax error, unexpected T_ECHO in /home/content/65/11493065/html/PHP/html_form_send.php on line 265 which is the echo at the end Many thanks <?php /* subject and email variables */ $subject = 'form completion'; $to = 'office@english-centre.co.uk'; /* gathering data variable */ $name = $_POST['name']; $telephone = $_POST['telephone']; $email = $_POST['email']; $type = $_POST['type']; $ability = $_POST['ability']; $previous_lessons = $_POST['previous_lessons']; $comments = $_POST['comments']; $found_site = $_POST['found_site']; $body = <<<EOD <br><hr><br> Client Name: $name <br> Telephone: $telephone <br> Email: $email <br> Intrested in: $type <br> Current ability: $ability <br> Previous lessons: $previous_lessons <br> Any comments: $comments <br> found site through: $found_site <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail ($to, $subject, $body, $headers); /* results rendered as HTML */ $theResults = <<<EOD <HTML> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- #BeginTemplate "Template.dwt" --> <head> <meta content="en-gb" http-equiv="Content-Language"> <!-- #BeginEditable "doctitle" --> <title>The English Centre 07905080578</title> <!-- #EndEditable --> <title>The English Centre</title> <link rel="stylesheet" href="../JS/gilbitron-Lean-Slider-ffe9a31/demo/style.css" type="text/css" media="screen" /> <script src="../JS/gilbitron-Lean-Slider-ffe9a31/demo/scripts/modernizr-2.6.1.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script src="../JS/gilbitron-Lean-Slider-ffe9a31/lean-slider.js"></script> <link rel="stylesheet" href="../JS/gilbitron-Lean-Slider-ffe9a31/lean-slider.css" type="text/css" /> <link rel="stylesheet" href="../JS/gilbitron-Lean-Slider-ffe9a31/demo/sample-styles.css" type="text/css" /> <link href="../CSS/styles.css" rel="stylesheet" type="text/css" media="screen"> <style type="text/css"> .auto-style1 { margin-bottom: 1em; } </style> </head> <body> <div id="wrapper"> <div id="top"> <div id="logo"> <img alt="English Centre" height="220" src="../Images/book-covered-in-uk.jpg" width="606"></div> <div id="language"> <h3 class="auto-style1">The English Centre </h3><br>07905080578<br> <a href="mailto:Office@english-centre.co.uk"> Office@english-centre.co.uk</a><br><br>Language Select<br><br> </div> </div> <div id="topna"> <ul> <li><a href="../default.html" class="button">Home</a></li> <li><a href="../French/default.html" class="button">About Us</a></li> <li><a href="courses.html" class="button">Courses</a></li> <li><a href="Teachers.html" class="button">Teachers</a></li> <li><a href="FAQ.html" class="button">FAQ</a></li> <li><a href="Contact.html" class="button">Contact</a></li> </ul> </div> <div class="slider-wrapper"> <div id="slider"> <div class="slide1"> <img src="../Images/big ben.jpg" alt="" /> </div> <div class="slide2"> <img src="../Images/main/hills.jpg" alt="" /> </div> <div class="slide3"> <img src="../Images/main/talking people.jpg" alt="" /> </div> <div class="slide4"> <img src="../Images/main/towerbridge.jpg" alt="" /> </div> </div> <div id="slider-direction-nav"></div> <div id="slider-control-nav"></div> </div> <script type="text/javascript"> $(document).ready(function() { var slider = $('#slider').leanSlider({ directionNav: '#slider-direction-nav', controlNav: '#slider-control-nav' }); }); </script> <div id="subbanner"> <marquee behavior="scroll" direction="left"><img alt="English lessons" height="72" src="../Images/main/scroll%20text.jpg" width="1188"></marquee> </div> <!-- #BeginEditable "Content" --> <div id="wrapper0"> <div id="content"> <h1>Contact Us</h1> <p>To find out more information complete the form and we will be in touch soon</p> <div id="form" style="width: 673px"> <form name="feedback" action="../PHP/html_form_send.php" method="post" style="width: 638px"> <ol> <li> <label for="name">Name</label> <input type="text" name="name" id="name"> </li> <li> <label for="telephone">Telephone</label> <input type="tel" name="telephone" id="telephone"> </li> <li> <label for="email">Email</label> <input type="email" name="email" id="email"> </li> <li> <label for="type">Type of Lesson</label> <select name="type"> <option value="single">Single Lessons</option> <option value="package">Lesson Package</option> <option value="friends">Learn with a Friend</option> </select></li> <li> <label for="ability">Current ability</label> <select name="ability"> <option value="beginner">Beginner</option> <option value="beyond beginner">Beyond Beginner</option> <option value="intermediate">Intermediate</option> <option value="fair">Fair</option> <option value="fluent">Fluent</option> </select></li> <li> <label for="previous_lessons">Previous Lessons?</label> <select name="previous_lessons"> <option value="no">No</option> <option value="school only">Learned only in School</option> <option value="over5years">Over 5 Years ago</option> <option value="5years">last 5 Years </option> <option value="2 years">Last 2 Years</option> <option value="pc only">Only on the Computer</option> </select></li> <li> <label for="comments">Comments</label> <textarea name="comments" style="width: 278px; height: 117px"></textarea> </li> <li> <label for="found_site">How did you find us?</label> <select name="found_site"> <option value="google">Google</option> <option value="bing">Bing</option> <option value="yahoo">Yahoo</option> <option value="gumtree">Gumtree</option> <option value="friend">Friend</option> <option value="flyer">Flyer</option> <option value="advert">Advert</option> <option value="other">Other</option> </select></li> <li> <label for="send">Send it</label> <input name="Submit1" type="submit" value="submit" /> </ol> </form> <h2 style="width: 667px"> Our goal is to help you speak fluently!</h2> </div> </div> </div> <div id="wrapper1"> <div id="rightside" style="width: 292px"> <h2> Our Other Services</h2> <ul> <li>Proofreading <li>Dissertation Writing/Proofreading <li>Essay Writing Service <li>CV Writing Service <li>Essay Writing Skills Class <li>Business Plan Writing <li>Marketing Plan Writing <li>PowerPoint Writing </ul> <p> </p> <p>If you require our other services or would like to submit a CV to work for the English Centre please use the email above</p> <img alt="Learn English" height="253" src="../Images/main/students.jpg" width="313"></h3> </div> </div> <!-- #EndEditable --> <!-- #BeginEditable "right%20side" --> <!-- #EndEditable --> <div id="footer"> <p>© Copywrite 2013 - The English Centre, London, UK</p> </div> </div> </body> <!-- #EndTemplate --> </html> EOD echo "$theResults"; ?>
  18. I've been trying to learn PHP with the PHP Solutions book second editions by David Powers. I seemingly can't find anyway of contacting him about the code I found in the book. <?php foreach ($_POST as $key => $value) { // assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); // if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { $missing[] = $key; } elseif (in_array($key, $expected)) { // otherwise, assign to a variable of the same name as $key ${$key} = $temp; } } I understand that is_array checks whether or not $value is an array but I can't find a scenario in which it would be array and therefore why it would be there at all. Also I the last part relies on the fact above which I don't understand as well.
  19. Hello phpfreaks I found a basic php upload script which i find really useful but I have a problem, I'm new to php programming and need help in this code: <? $upload = $_GET["upload"]; if ($upload == "now") { $path1 = "uploads/"; $path="$path1".$_FILES['ufile']['name']; if($ufile !=none) { if(copy($_FILES['ufile']['tmp_name'], $path)) { echo "Success!<BR/>"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=uploads/\">"; } else { echo "<font color=red><b>Error!</b></font>"; } } } else { ?> <table width="250" border="0" align="left" cellpadding="0" cellspacing="1"> <tr> <form action="?upload=now" method="post" enctype="multipart/form-data"> <td> <table border="0" cellpadding="3" cellspacing="1"> <tr> <td>Select file <input name="ufile" type="file" id="ufile" /></td> </tr> <tr> <td align="left"><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </td> </form> </tr> </table> <a href="uploads">View Uploads</a> <? } ?> I want the script to change the name of a file to random numbers after being uploaded for example: If a person uploaded a file called: "catherine.jpg" The script will automatically rename it to: "1231421421421.jpg" while providing a link to the uploaded file. How can I do that? any help would be appreciated Thanks in advance, and sorry for my bad english.
  20. Hi, I don't know what i am doing wrong. I have two php files, Page1.php has a summation ($Profit 2012) and i want to import the result of that variable into a Page2.php. Page1.php <?PHP $Gain2012 = 500; $Loss2012 = 200; $Profit2012 = $Gain2012 - $Loss2012; ?> Page2.php <?PHP $Profit2012 = ob_start(); include 'Page1.php'; ob_end_clean(); $Profit; $Gain2013 = 100; $Loss2013 = 50; $Profit2013 = $Gain2013 - $Loss2013; $ProfitSum = $Profit2012 + $Profit2013; ?> As output for $Profit2012 in Page2.php, i get the data 1 instead of 300.
  21. Hi, My workplace have bought a script to run our online car sales (www.woodleighcars.co.uk), and I've been given the thankless task of setting it up because I know a bit of html! I've managed to get most of it done but am now pulling my hair out. The seller won't help. On each advert there's an option to "Print Page" and all I want to do is when you select the print option and the printable page appears, its to move the "Price" field from the specifications table, next to the cars title at the top of the advert. I'll be honest, I've tried everything and my heads spinning. Can anyone help? flyer.php view.php
  22. Hi there, I have a question that I seem not to be able to find online else so I'm hoping someone here can help me. The question I have is I am in the process of creating a membership site. I have completed the login process correctly with a PHP login script I found online. I have installed the script correctly such as database, protecting certain pages etc. The problem I am having is I am wanting to hide the URL where the registration page is found where users can signup (e.g. mywebsite.com/register.php). For example, I am wanting users to be able to login any time (mywebsite.com/login.php from a link I provide on the home page), but I am wanting to hide the signup page as user will get access to the registration page once they have made payments. But the problem is if the user has a little bit of knowledge about login scripts, there should know just to type in either signup.php or register.php (where the login script is located) to get access to this page for free. For example, could I some how change the register.php name to something like register229102.php without the entire script not working? The idea behind my membership site will be once a user makes a payment via redirecting to a secure Clickbank payments page (as I am using Clickbank as my payment options) and once the user has made payments they are then redirected to the thank you page, when then the user will click a link to be redirected to the register.php page where they sign up and get access from there. And they can login from the home page once they have become a member. I hope this has made an understanding of my idea. I have everything already set up and would just like an easy way to hind the register.php URL as I am not to techy when it comes to PHP. Thanks Kindly, Daniel
  23. hello, I have an employee in / out board that someone else coded, and I am trying to generate a report from a table of data. I have the logic in my head, just not sure how to get it down to work correctly. It's currently written in PHP with a mysql database backend. For example. Data Table: ---------------------------------------------------------------- ID - NAME - DIRECTION - DATED - DATET ---------------------------------------------------------------- 37 Employee1 2 2012-09-09 20:53:25 37 Employee1 1 2012-09-09 20:53:33 39 Employee2 2 2012-09-10 07:58:51 37 Employee1 2 2012-09-10 09:08:56 39 Employee2 1 2012-09-10 17:03:29 37 Employee1 1 2012-09-10 17:10:47 37 Employee1 2 2012-09-11 08:14:14 39 Employee2 2 2012-09-11 08:14:22 37 Employee1 1 2012-09-11 12:51:59 39 Employee2 1 2012-09-11 12:53:12 37 Employee1 2 2012-09-11 14:44:26 39 Employee2 2 2012-09-11 14:44:36 39 Employee2 1 2012-09-11 14:44:36 39 Employee2 2 2012-09-11 14:44:36 39 Employee2 1 2012-09-11 16:43:59 37 Employee1 1 2012-09-11 17:16:26 ---------------------------------------------------------------- Direction (From Above) 1 = Out 2 = In ----------------------------------------------------- I'm going to create a couple of different reports, but the first one will look like: Name Date Time In Time Out Time In Time Out Total Time: --------------------------------------------------------------------------------------- Employee1 9/9/12 20:53 20:53 0:00 9/10/12 09:08 17:10 8:02 9/11/12 08:14 12:51 14:44 17:16 7:09 ----------- 15:11 Employee2 9/10/12 7:58 17:03 9:05 9/11/12 8:14 12:53 14:44 16:43 7:11 ----------- 16:16 can someone point me in the right direction for this ? thanks
  24. hi i am creating a website where a user can post a title,upload an image, description of image and description of ad and with this i keep getting error writing to database could somebody help me with this code thanks. also i need to insert current date into the database thanks. <?php if ( !isset($_FILES['userFile']['type']) ) { die('<p>No image submitted</p></body></html>'); } ?> You submitted this file:<br /><br /> Temporary name: <?php echo $_FILES['userFile']['tmp_name'] ?><br /> Original name: <?php echo $_FILES['userFile']['name'] ?><br /> Size: <?php echo $_FILES['userFile']['size'] ?> bytes<br /> Type: <?php echo $_FILES['userFile']['type'] ?></p> <?php require 'mysql.php'; $title=$_POST['title']; $description=$_POST['description']; // Validate uploaded image file if ( !preg_match( '/gif|png|x-png|jpeg/', $_FILES['userFile']['type']) ) { die('<p>Only browser compatible images allowed</p></body></html>'); } else if ( strlen($_POST['altText']) < 9 ) { die('<p>Please provide meaningful alternate text</p></body></html>'); } else if ( $_FILES['userFile']['size'] > 16384 ) { die('<p>Sorry file too large</p></body></html>'); // Connect to database } else if ( !($link=mysql_connect($host, $user, $passwd)) ) { die('<p>Error connecting to database</p></body></html>'); } else if ( !(mysql_select_db($dbName)) ) { die('<p>Error selecting database</p></body></html>'); // Copy image file into a variable } else if ( !($handle = fopen ($_FILES['userFile']['tmp_name'], "r")) ) { die('<p>Error opening temp file</p></body></html>'); } else if ( !($image = fread ($handle, filesize($_FILES['userFile']['tmp_name']))) ) { die('<p>Error reading temp file</p></body></html>'); } else { fclose ($handle); // Commit image to the database $image = mysql_real_escape_string($image); $alt = htmlentities($_POST['altText']); $query = 'INSERT INTO image (title,type,name,alt,img,description,date) VALUES ("' . $title . '","' . $_FILES['userFile']['type'] . '","' . $_FILES['userFile']['name'] . '","' . $alt . '","' . $image . '","' . $description . '","' . $NOW() . '")'; if ( !(mysql_query($query,$link)) ) { die('<p>Error writing image to database</p></body></html>'); } else { die('<p>Image successfully copied to database</p></body></html>'); } } ?>
  25. i keep getting this error all the time i don't understand why this is happening could someone please help me. <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb"> <body> <h1>image upload to freecycle</h1><p> <?php require 'auth.php'; if(isset($_SESSION['loggedin'])){ //session is set, user is logged in }else{ header("http://stuweb.cms.gre.ac.uk/~sn027/login.html"); if ( !isset($_FILES['userFile']['type']) ) { die('<p>No image submitted</p></body></html>'); } ?> <body> <h1>Uploading Images to MySQL</h1><p> <?php if ( !isset($_FILES['userFile']['type']) ) { die('<p>No image submitted</p></body></html>'); } ?> You submitted this file:<br /><br /> Temporary name: <?php echo $_FILES['userFile']['tmp_name'] ?><br /> Original name: <?php echo $_FILES['userFile']['name'] ?><br /> Size: <?php echo $_FILES['userFile']['size'] ?> bytes<br /> Type: <?php echo $_FILES['userFile']['type'] ?></p> <?php require 'mysql.php'; // Validate uploaded image file if ( !preg_match( '/gif|png|x-png|jpeg/', $_FILES['userFile']['type']) ) { die('<p>Only browser compatible images allowed</p></body></html>'); } else if ( strlen($_POST['altText']) < 9 ) { die('<p>Please provide meaningful alternate text</p></body></html>'); } else if ( $_FILES['userFile']['size'] > 16384 ) { die('<p>Sorry file too large</p></body></html>'); // Connect to database } else if ( !($link=mysql_connect($host, $user, $passwd)) ) { die('<p>Error connecting to database</p></body></html>'); } else if ( !(mysql_select_db($dbName)) ) { die('<p>Error selecting database</p></body></html>'); // Copy image file into a variable } else if ( !($handle = fopen ($_FILES['userFile']['tmp_name'], "r")) ) { die('<p>Error opening temp file</p></body></html>'); } else if ( !($image = fread ($handle, filesize($_FILES['userFile']['tmp_name']))) ) { die('<p>Error reading temp file</p></body></html>'); } else { fclose ($handle); // Commit image to the database $image = mysql_real_escape_string($image); $alt = htmlentities($_POST['altText']); $query = 'INSERT INTO image (title,type,name,alt,img,description) VALUES ("' . $_FILES['userFile']['type'] . '","' . $_FILES['userFile']['name'] . '","' . $alt . '","' . $image . '")'; if ( !(mysql_query($query,$link)) ) { die('<p>Error writing image to database</p></body></html>'); } else { die('<p>Image successfully copied to database</p></body></html>'); } }
×
×
  • 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.