PHP - Confused Timer Script
Hello.
Well I am really annoyed at myself at the moment. I am trying to make a timer script that is uninterrupted by a refresh of the page, so this to me would be a Mysql database thing to check My idea was simple, at least until I forgot it. But, I was going to grab the current time using time(); and place it into the database. Then I would set another value in the structure called check, to 1. The database while the value is set on 1 will keep checking every time a user refreshes. It would get the time from the database that was set, and the current time again. It would take away the stored time from the current time and if that value equals less then ten, it would keep running the script and won't change the check. But if it was over ten, it would do a random function (What ever the user wanted, right now it just an echo for a test) and delete both the current timestamp in the database, and set the check to 0. If the value was 0, it would set the new timestamp in the database, eg the current time, and set the value to 1 so it will keep running again. Is this possible? It is getting a bit annoying, getting a few errors, again like most of the time its little ones that I can't seem to put my finger on. Hey, we have all started somewhere :/ This is my code so fa Code: [Select] <?php $db = mysql_pconnect("localhost","root",""); mysql_select_db("test",$db); $time = time(); $result = mysql_query("SELECT * FROM timer"); while($row = mysql_fetch_array($result)) { $timestamp = $row['timestamp']; $check = $row['check']; } if ($check=="0") { $query = "UPDATE timer SET check = '1' WHERE id = '1'"; $query .= "UPDATE timer SET timestamp = '$time' WHERE id = '1'"; multi_query($query); } elseif ($check=="1") { $timenow = time(); $timecheck = $timenow - $timestamp; if ($timecheck >= "10") { echo "bigger then 10, do what ever at the end of the countdown here"; $query2 = "UPDATE timer SET check = '0' WHERE id = '1'"; $query2 .= "UPDATE timer SET timestamp = '' WHERE id = '1'"; multi_query($query2); } } ?> Now even looking at this code confuses me, and I wrote it. I tested it, I expected an error and got one. Quote Parse error: syntax error, unexpected T_ELSEIF in D:\xampp\htdocs\tests\timer.php on line 17 As you have probably already stated, I am a very small form of BASIC at PHP, would anyone like to push me in the right direction as to how to get this working? Similar TutorialsHi friends,
I have this script for countdown Timer, and when i open my site the timer show Nan, can you help me please
/* http://keith-wood.name/countdown.html Countdown for jQuery v2.0.0. Written by Keith Wood (kbwood{at}iinet.com.au) January 2008. Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. Please attribute the author if you use it. */ (function($) { // Hide scope, no $ conflict var pluginName = 'countdown'; var Y = 0; // Years var O = 1; // Months var W = 2; // Weeks var D = 3; // Days var H = 4; // Hours var M = 5; // Minutes var S = 6; // Seconds /** Create the countdown plugin. <p>Sets an element to show the time remaining until a given instant.</p> <p>Expects HTML like:</p> <pre><div></div></pre> <p>Provide inline configuration like:</p> <pre><div data-countdown="name: 'value'"></div></pre> @module Countdown @augments JQPlugin @example $(selector).countdown({until: +300}) */ $.JQPlugin.createPlugin({ /** The name of the plugin. */ name: pluginName, /** Countdown expiry callback. Triggered when the countdown expires. @callback expiryCallback */ /** Countdown server synchronisation callback. Triggered when the countdown is initialised. @callback serverSyncCallback @return {Date} The current date/time on the server as expressed in the local timezone. */ /** Countdown tick callback. Triggered on every <code>tickInterval</code> ticks of the countdown. @callback tickCallback @param periods {number[]} The breakdown by period (years, months, weeks, days, hours, minutes, seconds) of the time remaining/passed. */ /** Countdown which labels callback. Triggered when the countdown is being display to determine which set of labels (<code>labels</code>, <code>labels1</code>, ...) are to be used for the current period value. @callback whichLabelsCallback @param num {number} The current period value. @return {number} The suffix for the label set to use. */ /** Default settings for the plugin. @property until {Date|number|string} The date/time to count down to, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @example until: new Date(2013, 12-1, 25, 13, 30) until: +300 until: '+1O -2D' @property [since] {Date|number|string} The date/time to count up from, or number of seconds offset from now, or string for unit offset(s): 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @example since: new Date(2013, 1-1, 1) since: -300 since: '-1O +2D' @property [timezone=null] {number} The timezone (hours or minutes from GMT) for the target times, or null for client local timezone. @example timezone: +10 timezone: -60 @property [serverSync=null] {serverSyncCallback} A function to retrieve the current server time for synchronisation. @property [format='dHMS'] {string} The format for display - upper case for always, lower case only if non-zero, 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @property [layout=''] {string} Build your own layout for the countdown. @example layout: '{d<}{dn} {dl}{d>} {hnn}:{mnn}:{snn}' @property [compact=false] {boolean} True to display in a compact format, false for an expanded one. @property [padZeroes=false] {boolean} True to add leading zeroes @property [significant=0] {number} The number of periods with non-zero values to show, zero for all. @property [description=''] {string} The description displayed for the countdown. @property [expiryUrl=''] {string} A URL to load upon expiry, replacing the current page. @property [expiryText=''] {string} Text to display upon expiry, replacing the countdown. This may be HTML. @property [alwaysExpire=false] {boolean} True to trigger <code>onExpiry</code> even if target time has passed. @property [onExpiry=null] {expiryCallback} Callback when the countdown expires - receives no parameters and <code>this</code> is the containing division. @example onExpiry: function() { ... } @property [onTick=null] {tickCallback} Callback when the countdown is updated - receives <code>number[7]</code> being the breakdown by period (years, months, weeks, days, hours, minutes, seconds - based on <code>format</code>) and <code>this</code> is the containing division. @example onTick: function(periods) { var secs = $.countdown.periodsToSeconds(periods); if (secs < 300) { // Last five minutes ... } } @property [tickInterval=1] {number} The interval (seconds) between <code>onTick</code> callbacks. */ defaultOptions: { until: null, since: null, timezone: null, serverSync: null, format: 'dHMS', layout: '', compact: false, padZeroes: false, significant: 0, description: '', expiryUrl: '', expiryText: '', alwaysExpi false, onExpiry: null, onTick: null, tickInterval: 1 }, /** Localisations for the plugin. Entries are objects indexed by the language code ('' being the default US/English). Each object has the following attributes. @property [labels=['Years','Months','Weeks','Days','Hours','Minutes','Seconds']] {string[]} The display texts for the counter periods. @property [labels1=['Year','Month','Week','Day','Hour','Minute','Second']] {string[]} The display texts for the counter periods if they have a value of 1. Add other <code>labels<em>n</em></code> attributes as necessary to cater for other numeric idiosyncrasies of the localisation. @property [compactLabels=['y','m','w','d']] {string[]} The compact texts for the counter periods. @property [whichLabels=null] {whichLabelsCallback} A function to determine which <code>labels<em>n</em></code> to use. @example whichLabels: function(num) { return (num > 1 ? 0 : 1); } @property [digits=['0','1',...,'9']] {number[]} The digits to display (0-9). @property [timeSeparator=':'] {string} Separator for time periods in the compact layout. @property [isRTL=false] {boolean} True for right-to-left languages, false for left-to-right. */ regionalOptions: { // Available regional settings, indexed by language/country code '': { // Default regional settings - English/US labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'], labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'], compactLabels: ['y', 'm', 'w', 'd'], whichLabels: null, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], timeSeparator: ':', isRTL: false } }, /** Names of getter methods - those that can't be chained. */ _getters: ['getTimes'], /* Class name for the right-to-left marker. */ _rtlClass: pluginName + '-rtl', /* Class name for the countdown section marker. */ _sectionClass: pluginName + '-section', /* Class name for the period amount marker. */ _amountClass: pluginName + '-amount', /* Class name for the period name marker. */ _periodClass: pluginName + '-period', /* Class name for the countdown row marker. */ _rowClass: pluginName + '-row', /* Class name for the holding countdown marker. */ _holdingClass: pluginName + '-holding', /* Class name for the showing countdown marker. */ _showClass: pluginName + '-show', /* Class name for the description marker. */ _descrClass: pluginName + '-descr', /* List of currently active countdown elements. */ _timerElems: [], /** Additional setup for the countdown. Apply default localisations. Create the timer. */ _init: function() { var self = this; this._super(); this._serverSyncs = []; var now = (typeof Date.now == 'function' ? Date.now : function() { return new Date().getTime(); }); var perfAvail = (window.performance && typeof window.performance.now == 'function'); // Shared timer for all countdowns function timerCallBack(timestamp) { var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer (perfAvail ? (performance.now() + performance.timing.navigationStart) : now()) : // Integer milliseconds since unix epoch timestamp || now()); if (drawStart - animationStartTime >= 1000) { self._updateElems(); animationStartTime = drawStart; } requestAnimationFrame(timerCallBack); } var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null; // This is when we expect a fall-back to setInterval as it's much more fluid var animationStartTime = 0; if (!requestAnimationFrame || $.noRequestAnimationFrame) { $.noRequestAnimationFrame = null; setInterval(function() { self._updateElems(); }, 980); // Fall back to good old setInterval } else { animationStartTime = window.animationStartTime || window.webkitAnimationStartTime || window.mozAnimationStartTime || window.oAnimationStartTime || window.msAnimationStartTime || now(); requestAnimationFrame(timerCallBack); } }, /** Convert a date/time to UTC. @param tz {number} The hour or minute offset from GMT, e.g. +9, -360. @param year {Date|number} the date/time in that timezone or the year in that timezone. @param [month] {number} The month (0 - 11) (omit if <code>year</code> is a <code>Date</code>). @param [day] {number} The day (omit if <code>year</code> is a <code>Date</code>). @param [hours] {number} The hour (omit if <code>year</code> is a <code>Date</code>). @param [mins] {number} The minute (omit if <code>year</code> is a <code>Date</code>). @param [secs] {number} The second (omit if <code>year</code> is a <code>Date</code>). @param [ms] {number} The millisecond (omit if <code>year</code> is a <code>Date</code>). @return {Date} The equivalent UTC date/time. @example $.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0) $.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0)) */ UTCDate: function(tz, year, month, day, hours, mins, secs, ms) { if (typeof year == 'object' && year.constructor == Date) { ms = year.getMilliseconds(); secs = year.getSeconds(); mins = year.getMinutes(); hours = year.getHours(); day = year.getDate(); month = year.getMonth(); year = year.getFullYear(); } var d = new Date(); d.setUTCFullYear(year); d.setUTCDate(1); d.setUTCMonth(month || 0); d.setUTCDate(day || 1); d.setUTCHours(hours || 0); d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz)); d.setUTCSeconds(secs || 0); d.setUTCMilliseconds(ms || 0); return d; }, /** Convert a set of periods into seconds. Averaged for months and years. @param periods {number[]} The periods per year/month/week/day/hour/minute/second. @return {number} The corresponding number of seconds. @example var secs = $.countdown.periodsToSeconds(periods) */ periodsToSeconds: function(periods) { return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 + periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6]; }, _instSettings: function(elem, options) { return {_periods: [0, 0, 0, 0, 0, 0, 0]}; }, /** Add an element to the list of active ones. @private @param elem {Element} The countdown element. */ _addElem: function(elem) { if (!this._hasElem(elem)) { this._timerElems.push(elem); } }, /** See if an element is in the list of active ones. @private @param elem {Element} The countdown element. @return {boolean} True if present, false if not. */ _hasElem: function(elem) { return ($.inArray(elem, this._timerElems) > -1); }, /** Remove an element from the list of active ones. @private @param elem {Element} The countdown element. */ _removeElem: function(elem) { this._timerElems = $.map(this._timerElems, function(value) { return (value == elem ? null : value); }); // delete entry }, /** Update each active timer element. @private */ _updateElems: function() { for (var i = this._timerElems.length - 1; i >= 0; i--) { this._updateCountdown(this._timerElems[i]); } }, _optionsChanged: function(elem, inst, options) { if (options.layout) { options.layout = options.layout.replace(/</g, '<').replace(/>/g, '>'); } this._resetExtraLabels(inst.options, options); var timezoneChanged = (inst.options.timezone != options.timezone); $.extend(inst.options, options); this._adjustSettings(elem, inst, options.until != null || options.since != null || timezoneChanged); var now = new Date(); if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) { this._addElem(elem[0]); } this._updateCountdown(elem, inst); }, /** Redisplay the countdown with an updated display. @private @param elem {Element|jQuery} The containing division. @param inst {object} The current settings for this instance. */ _updateCountdown: function(elem, inst) { elem = elem.jquery ? elem : $(elem); inst = inst || elem.data(this.name); if (!inst) { return; } elem.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL); if ($.isFunction(inst.options.onTick)) { var periods = inst._hold != 'lap' ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()); if (inst.options.tickInterval == 1 || this.periodsToSeconds(periods) % inst.options.tickInterval == 0) { inst.options.onTick.apply(elem[0], [periods]); } } var expired = inst._hold != 'pause' && (inst._since ? inst._now.getTime() < inst._since.getTime() : inst._now.getTime() >= inst._until.getTime()); if (expired && !inst._expiring) { inst._expiring = true; if (this._hasElem(elem[0]) || inst.options.alwaysExpire) { this._removeElem(elem[0]); if ($.isFunction(inst.options.onExpiry)) { inst.options.onExpiry.apply(elem[0], []); } if (inst.options.expiryText) { var layout = inst.options.layout; inst.options.layout = inst.options.expiryText; this._updateCountdown(elem[0], inst); inst.options.layout = layout; } if (inst.options.expiryUrl) { window.location = inst.options.expiryUrl; } } inst._expiring = false; } else if (inst._hold == 'pause') { this._removeElem(elem[0]); } }, /** Reset any extra labelsn and compactLabelsn entries if changing labels. @private @param base {object} The options to be updated. @param options {object} The new option values. */ _resetExtraLabels: function(base, options) { var changingLabels = false; for (var n in options) { if (n != 'whichLabels' && n.match(/[Ll]abels/)) { changingLabels = true; break; } } if (changingLabels) { for (var n in base) { // Remove custom numbered labels if (n.match(/[Ll]abels[02-9]|compactLabels1/)) { base[n] = null; } } } }, /** Calculate internal settings for an instance. @private @param elem {jQuery} The containing division. @param inst {object} The current settings for this instance. @param recalc {boolean} True if until or since are set. */ _adjustSettings: function(elem, inst, recalc) { var now; var serverOffset = 0; var serverEntry = null; for (var i = 0; i < this._serverSyncs.length; i++) { if (this._serverSyncs[i][0] == inst.options.serverSync) { serverEntry = this._serverSyncs[i][1]; break; } } if (serverEntry != null) { serverOffset = (inst.options.serverSync ? serverEntry : 0); now = new Date(); } else { var serverResult = ($.isFunction(inst.options.serverSync) ? inst.options.serverSync.apply(elem[0], []) : null); now = new Date(); serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0); this._serverSyncs.push([inst.options.serverSync, serverOffset]); } var timezone = inst.options.timezone; timezone = (timezone == null ? -now.getTimezoneOffset() : timezone); if (recalc || (!recalc && inst._until == null && inst._since == null)) { inst._since = inst.options.since; if (inst._since != null) { inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null)); if (inst._since && serverOffset) { inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset); } } inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now)); if (serverOffset) { inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset); } } inst._show = this._determineShow(inst); }, /** Remove the countdown widget from a div. @param elem {jQuery} The containing division. @param inst {object} The current instance object. */ _preDestroy: function(elem, inst) { this._removeElem(elem[0]); elem.empty(); }, /** Pause a countdown widget at the current time. Stop it running but remember and display the current time. @param elem {Element} The containing division. @example $(selector).countdown('pause') */ pause: function(elem) { this._hold(elem, 'pause'); }, /** Pause a countdown widget at the current time. Stop the display but keep the countdown running. @param elem {Element} The containing division. @example $(selector).countdown('lap') */ lap: function(elem) { this._hold(elem, 'lap'); }, /** Resume a paused countdown widget. @param elem {Element} The containing division. @example $(selector).countdown('resume') */ resume: function(elem) { this._hold(elem, null); }, /** Toggle a paused countdown widget. @param elem {Element} The containing division. @example $(selector).countdown('toggle') */ toggle: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'pause' : 'resume'](elem); }, /** Toggle a lapped countdown widget. @param elem {Element} The containing division. @example $(selector).countdown('toggleLap') */ toggleLap: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'lap' : 'resume'](elem); }, /** Pause or resume a countdown widget. @private @param elem {Element} The containing division. @param hold {string} The new hold setting. */ _hold: function(elem, hold) { var inst = $.data(elem, this.name); if (inst) { if (inst._hold == 'pause' && !hold) { inst._periods = inst._savePeriods; var sign = (inst._since ? '-' : '+'); inst[inst._since ? '_since' : '_until'] = this._determineTime(sign + inst._periods[0] + 'y' + sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' + sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' + sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's'); this._addElem(elem); } inst._hold = hold; inst._savePeriods = (hold == 'pause' ? inst._periods : null); $.data(elem, this.name, inst); this._updateCountdown(elem, inst); } }, /** Return the current time periods. @param elem {Element} The containing division. @return {number[]} The current periods for the countdown. @example var periods = $(selector).countdown('getTimes') */ getTimes: function(elem) { var inst = $.data(elem, this.name); return (!inst ? null : (inst._hold == 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())))); }, /** A time may be specified as an exact value or a relative one. @private @param setting {string|number|Date} The date/time value as a relative or absolute value. @param defaultTime {Date} The date/time to use if no other is supplied. @return {Date} The corresponding date/time. */ _determineTime: function(setting, defaultTime) { var self = this; var offsetNumeric = function(offset) { // e.g. +300, -2 var time = new Date(); time.setTime(time.getTime() + offset * 1000); return time; }; var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m' offset = offset.toLowerCase(); var time = new Date(); var year = time.getFullYear(); var month = time.getMonth(); var day = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g; var matches = pattern.exec(offset); while (matches) { switch (matches[2] || 's') { case 's': second += parseInt(matches[1], 10); break; case 'm': minute += parseInt(matches[1], 10); break; case 'h': hour += parseInt(matches[1], 10); break; case 'd': day += parseInt(matches[1], 10); break; case 'w': day += parseInt(matches[1], 10) * 7; break; case 'o': month += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; case 'y': year += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; } matches = pattern.exec(offset); } return new Date(year, month, day, hour, minute, second, 0); }; var time = (setting == null ? defaultTime : (typeof setting == 'string' ? offsetString(setting) : (typeof setting == 'number' ? offsetNumeric(setting) : setting))); if (time) time.setMilliseconds(0); return time; }, /** Determine the number of days in a month. @private @param year {number} The year. @param month {number} The month. @return {number} The days in that month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /** Default implementation to determine which set of labels should be used for an amount. Use the <code>labels</code> attribute with the same numeric suffix (if it exists). @private @param num {number} The amount to be displayed. @return {number} The set of labels to be used for this amount. */ _normalLabels: function(num) { return num; }, /** Generate the HTML to display the countdown widget. @private @param inst {object} The current settings for this instance. @return {string} The new HTML for the countdown display. */ _generateHTML: function(inst) { var self = this; // Determine what to show inst._periods = (inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())); // Show all 'asNeeded' after first non-zero value var shownNonZero = false; var showCount = 0; var sigCount = inst.options.significant; var show = $.extend({}, inst._show); for (var period = Y; period <= S; period++) { shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0); show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]); showCount += (show[period] ? 1 : 0); sigCount -= (inst._periods[period] > 0 ? 1 : 0); } var showSignificant = [false, false, false, false, false, false, false]; for (var period = S; period >= Y; period--) { // Determine significant periods if (inst._show[period]) { if (inst._periods[period]) { showSignificant[period] = true; } else { showSignificant[period] = sigCount > 0; sigCount--; } } } var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels); var whichLabels = inst.options.whichLabels || this._normalLabels; var showCompact = function(period) { var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])]; return (show[period] ? self._translateDigits(inst, inst._periods[period]) + (labelsNum ? labelsNum[period] : labels[period]) + ' ' : ''); }; var minDigits = (inst.options.padZeroes ? 2 : 1); var showFull = function(period) { var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])]; return ((!inst.options.significant && show[period]) || (inst.options.significant && showSignificant[period]) ? '<span class="' + self._sectionClass + '">' + '<span class="' + self._amountClass + '">' + self._minDigits(inst, inst._periods[period], minDigits) + '</span>' + '<span class="' + self._periodClass + '">' + (labelsNum ? labelsNum[period] : labels[period]) + '</span></span>' : ''); }; return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout, inst.options.compact, inst.options.significant, showSignificant) : ((inst.options.compact ? // Compact version '<span class="' + this._rowClass + ' ' + this._amountClass + (inst._hold ? ' ' + this._holdingClass : '') + '">' + showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) + (show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') + (show[M] ? (show[H] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[M], 2) : '') + (show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[S], 2) : '') : // Full version '<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) + (inst._hold ? ' ' + this._holdingClass : '') + '">' + showFull(Y) + showFull(O) + showFull(W) + showFull(D) + showFull(H) + showFull(M) + showFull(S)) + '</span>' + (inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' + inst.options.description + '</span>' : ''))); }, /** Construct a custom layout. @private @param inst {object} The current settings for this instance. @param show {boolean[]} Flags indicating which periods are requested. @param layout {string} The customised layout. @param compact {boolean} True if using compact labels. @param significant {number} The number of periods with values to show, zero for all. @param showSignificant {boolean[]} Other periods to show for significance. @return {string} The custom HTML. */ _buildLayout: function(inst, show, layout, compact, significant, showSignificant) { var labels = inst.options[compact ? 'compactLabels' : 'labels']; var whichLabels = inst.options.whichLabels || this._normalLabels; var labelFor = function(index) { return (inst.options[(compact ? 'compactLabels' : 'labels') + whichLabels(inst._periods[index])] || labels)[index]; }; var digit = function(value, position) { return inst.options.digits[Math.floor(value / position) % 10]; }; var subs = {desc: inst.options.description, sep: inst.options.timeSeparator, yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1), ynn: this._minDigits(inst, inst._periods[Y], 2), ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1), y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100), y1000: digit(inst._periods[Y], 1000), ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1), onn: this._minDigits(inst, inst._periods[O], 2), onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1), o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100), o1000: digit(inst._periods[O], 1000), wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1), wnn: this._minDigits(inst, inst._periods[W], 2), wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1), w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100), w1000: digit(inst._periods[W], 1000), dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1), dnn: this._minDigits(inst, inst._periods[D], 2), dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1), d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100), d1000: digit(inst._periods[D], 1000), hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1), hnn: this._minDigits(inst, inst._periods[H], 2), hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1), h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100), h1000: digit(inst._periods[H], 1000), ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1), mnn: this._minDigits(inst, inst._periods[M], 2), mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1), m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100), m1000: digit(inst._periods[M], 1000), sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1), snn: this._minDigits(inst, inst._periods[S], 2), snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1), s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100), s1000: digit(inst._periods[S], 1000)}; var html = layout; // Replace period containers: {p<}...{p>} for (var i = Y; i <= S; i++) { var period = 'yowdhms'.charAt(i); var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g'); html = html.replace(re, ((!significant && show[i]) || (significant && showSignificant[i]) ? '$1' : '')); } // Replace period values: {pn} $.each(subs, function(n, v) { var re = new RegExp('\\{' + n + '\\}', 'g'); html = html.replace(re, v); }); return html; }, /** Ensure a numeric value has at least n digits for display. @private @param inst {object} The current settings for this instance. @param value {number} The value to display. @param len {number} The minimum length. @return {string} The display text. */ _minDigits: function(inst, value, len) { value = '' + value; if (value.length >= len) { return this._translateDigits(inst, value); } value = '0000000000' + value; return this._translateDigits(inst, value.substr(value.length - len)); }, /** Translate digits into other representations. @private @param inst {object} The current settings for this instance. @param value {string} The text to translate. @return {string} The translated text. */ _translateDigits: function(inst, value) { return ('' + value).replace(/[0-9]/g, function(digit) { return inst.options.digits[digit]; }); }, /** Translate the format into flags for each period. @private @param inst {object} The current settings for this instance. @return {string[]} Flags indicating which periods are requested (?) or required (!) by year, month, week, day, hour, minute, second. */ _determineShow: function(inst) { var format = inst.options.format; var show = []; show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null)); show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null)); show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null)); show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null)); show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null)); show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null)); show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null)); return show; }, /** Calculate the requested periods between now and the target time. @private @param inst {object} The current settings for this instance. @param show {string[]} Flags indicating which periods are requested/required. @param significant {number} The number of periods with values to show, zero for all. @param now {Date} The current date and time. @return {number[]} The current time periods (always positive) by year, month, week, day, hour, minute, second. */ _calculatePeriods: function(inst, show, significant, now) { // Find endpoints inst._now = now; inst._now.setMilliseconds(0); var until = new Date(inst._now.getTime()); if (inst._since) { if (now.getTime() < inst._since.getTime()) { inst._now = now = until; } else { now = inst._since; } } else { until.setTime(inst._until.getTime()); if (now.getTime() > inst._until.getTime()) { inst._now = now = until; } } // Calculate differences by period var periods = [0, 0, 0, 0, 0, 0, 0]; if (show[Y] || show[O]) { // Treat end of months as the same var lastNow = this._getDaysInMonth(now.getFullYear(), now.getMonth()); var lastUntil = this._getDaysInMonth(until.getFullYear(), until.getMonth()); var sameDay = (until.getDate() == now.getDate() || (until.getDate() >= Math.min(lastNow, lastUntil) && now.getDate() >= Math.min(lastNow, lastUntil))); var getSecs = function(date) { return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds(); }; var months = Math.max(0, (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() + ((until.getDate() < now.getDate() && !sameDay) || (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0)); periods[Y] = (show[Y] ? Math.floor(months / 12) : 0); periods[O] = (show[O] ? months - periods[Y] * 12 : 0); // Adjust for months difference and end of month if necessary now = new Date(now.getTime()); var wasLastDay = (now.getDate() == lastNow); var lastDay = this._getDaysInMonth(now.getFullYear() + periods[Y], now.getMonth() + periods[O]); if (now.getDate() > lastDay) { now.setDate(lastDay); } now.setFullYear(now.getFullYear() + periods[Y]); now.setMonth(now.getMonth() + periods[O]); if (wasLastDay) { now.setDate(lastDay); } } var diff = Math.floor((until.getTime() - now.getTime()) / 1000); var extractPeriod = function(period, numSecs) { periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0); diff -= periods[period] * numSecs; }; extractPeriod(W, 604800); extractPeriod(D, 86400); extractPeriod(H, 3600); extractPeriod(M, 60); extractPeriod(S, 1); if (diff > 0 && !inst._since) { // Round up if left overs var multiplier = [1, 12, 4.3482, 7, 24, 60, 60]; var lastShown = S; var max = 1; for (var period = S; period >= Y; period--) { if (show[period]) { if (periods[lastShown] >= max) { periods[lastShown] = 0; diff = 1; } if (diff > 0) { periods[period]++; diff = 0; lastShown = period; max = 1; } } max *= multiplier[period]; } } if (significant) { // Zero out insignificant periods for (var period = Y; period <= S; period++) { if (significant && periods[period]) { significant--; } else if (!significant) { periods[period] = 0; } } } return periods; } }); })(jQuery); Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>"; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END This shows all my subforums on my forum, but 1 problem, if I try to seperate them, like let's say with a "comma" by using: Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END It will show the , BEFORE the link? so weird, here is the function: Code: [Select] $forum_data['subforums'] = "<br> <span class=desc4>Subforums:</span> "; foreach($this->children[ $forum_data['id'] ] as $idx => $data) { //-------------------------------------- // Check permissions... //-------------------------------------- if ( $std->check_perms($data['read_perms']) != TRUE ) { continue; } // Do the news stuff first if (isset($data['last_title']) and $data['last_id'] != "") { if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) ) { $this->news_topic_id = $data['last_id']; $this->news_forum_id = $data['id']; $this->news_title = $data['last_title']; } } if ($data['last_post'] > $newest['last_post']) { //Subforum last_title? $newest['last_post'] = $data['last_post']; $newest['fid'] = $data['id']; //$newest['id'] = $data['id']; $newest['last_id'] = $data['last_id']; $newest['last_title'] = $data['last_title']; $newest['password'] = $data['password']; $newest['last_poster_id'] = $data['last_poster_id']; $newest['last_poster_name'] = $data['last_poster_name']; $newest['status'] = $data['status']; $newest['star'] = $data['star']; } $newest['posts'] += $data['posts']; $newest['topics'] += $data['topics']; $printed_children++; //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END } How can I make it so it doesn't show the , before the FIRST link on that subforums variable, but only after every link and beyond? Okay I got it working by moving it ontop Code: [Select] $forum_data['subforums'] .= "<a href=?z={$data[id]}>{$data['name']}</a>, "; //mod_KaLiTe_Subforums END $printed_children++; but now it shows the , after the last link, how do I make it so it doesn't show the comma for the last child? So just seen this http://www.ultramegatech.com/2009/07/using-mysql-prepared-statements-in-php/ from another topic, and am a bit confused now, I started coding a little while back, but did not get introduced to mysqli until very recently, should I change all my normal mysql queries to the mysqli prepared statements like in the website/tutorial stated? does this mean I won't have to use mysql_real_escape_string and it is more secure in general? Would really like some input, much appreciated. Hi there, I have been following this tutorial: http://www.freewebmasterhelp.com/tutorials/phpmysql/6 I have everything working, but I am a little confused when it comes to the "Links for Single Records" part. The following code snippet is what I am using to display the data that is in the database on the page after it is inserted, inside of a table. It is working fine, but the "edit" link just brings up a blank page, that has my edit code on it. Code: [Select] <table border="1" bordercolor="#000000" cellspacing="2" cellpadding="10"> <tr> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Name</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">E-Mail</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Age</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Gender</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Location</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Home Phone</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Other Phone</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Best Time to Reach</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2">Referrer</font></th> <th bgcolor="#01337f"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Options</font></th> </tr> <? $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $email=mysql_result($result,$i,"email"); $age=mysql_result($result,$i,"age"); $gender=mysql_result($result,$i,"gender"); $location=mysql_result($result,$i,"location"); $homephone=mysql_result($result,$i,"homephone"); $otherphone=mysql_result($result,$i,"otherphone"); $besttime=mysql_result($result,$i,"besttime"); $referrer=mysql_result($result,$i,"referrer"); ?> <tr> <td><font class="lead_txt"><? echo $name; ?></font></td> <td><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $email; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $age; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $gender; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $location; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $homephone; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $otherphone; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $besttime; ?></font></td> <td align="center"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $referrer; ?></font></td> <td bgcolor="#01337f""><a href="db_edit.php?id=$id"><img src="edit.png" width="25" height="25" alt="Edit"></a> <a href=""><img src="delete.png" width="25" height="25" alt="Delete"></a> <a href=""><img src="email.png" width="25" height="25" alt="E-Mail"></a></td> </tr> Any ideas? Thanks in advance!! Hi I'm trying to do a php website using notepad++ but when I save it and I test it out on a web browser it gives me my coding instead of a form. How do I fix this. Thank you why does this code display this webpage? brandysstudioofdance.com/checkOut.php Code: [Select] <?php session_start(); if (isset($_SESSION['cart'])){ foreach ($_SESSION['cart'] as $key => $value){ //echo "Product Number $key Quantity $value<br />"; } } require_once("functions.php"); //DatabaseConnection(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ordering doggy treats</title> <link href="doggyTreats.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #order { margin-right: auto; margin-left: auto; } .orderRow{ padding-bottom: 50px; } h2 { text-align: center; } </style> </head> <body> <?php $errors=array(); if(isset($_POST['submit'])){ validate_input(); if(count($errors) !=0) { display_form(); } else { display_form(); } function validate_input() { global $errors; if($_POST["fname"] == " ") { $errors['fname']="<span style=\"color:red;\"> Please enter your first name </span>"; } } } //logo(); navBar(); extract($_POST); if(!isset($submit)) { echo "<table id=\"order\">"; function display_form() { global $errors; ?> <form action="php_self" method="post" name="checkOut"> <caption><h2>Customer Information </h2> </caption> <tr class = "orderRow"> <td> First Name:<br /> <input name="fname" type="text" size="10" maxlength="20" value="<?php echo $_POST[fname] ?>"> <br /> <br /> <!--<?php echo $errors['fname']; ?> --> </td> <td> Last Name: <br /> <input name="lname" type="text" size="10" maxlength="20" /> </td> <td> Address: <br /> <input name="address " type="text" size="25" /> </td> </tr> <tr class = "orderRow"> <td> City: <br /> <input name="city " type="text" size="15" maxlength="20" /> </td> <td> State: <br /> <select name = "state"> <option selected value ="Please choose a state"/> Please choose a state</option> <option value = "AL" />AL</option> <option value = "AK" />AK</option> <option value = "AR" />AR</option> <option value = "AZ" />AZ <option value = "CA" />CA <option value = "CO" />CO <option value = "CT" />CT <option value = "DE" />DE <option value = "DC" />DC <option value = "FL" />FL <option value = "GA" />GA <option value = "HI" />HI <option value = "IA" />IA <option value = "ID" />ID <option value = "IL" />IL <option value = "IN" />IN <option value = "KS" />KS <option value = "KY" />KY <option value = "LA" />LA <option value = "MA" />MA <option value = "ME" />ME <option value = "MD" />MD <option value = "MI" />MI <option value = "MN" />MN <option value = "MO" />MO <option value = "MS" />MS <option value = "MT" />MT <option value = "NC" />NC <option value = "ND" />ND <option value = "NE" />NE <option value = "NH" />NH <option value = "NJ" />NJ <option value = "NM" />NM <option value = "OH" />OH <option value = "OK" />OK <option value = "OR" />OR <option value = "PA" />PA <option value = "RI" />RI <option value = "SC" />SC <option value = "SD" />SD <option value = "TN" />TN <option value = "TX" />TX <option value = "UT" />UT <option value = "VA" />VA <option value = "VT" />VT <option value = "WA" />WA <option value = "WI" />WI <option value = "WV" />WV <option value = "WY" />WY </select> </td> <td> Zip Code:<br /> <input name="zipcode" type="text" size="5" maxlength="5" /> </td> </tr> <tr class = "orderRow"> <td> Phone <br /> Please include area code <br /> <input name="phone" type="text" size="13" maxlength="13" /> </td> <td> Fax:<br /> <input name="" type="text" size="13" maxlength="13" /> </td> <td> Email: <br /> <input name="email " type="text" size="15" maxlength="30" /> </td> </tr> <tr class = "orderRow"> <td> Please choose method of payment: <br /> Check <input name="check " type="radio" value="Check " /> Money Order <input name="money " type="radio" value="Money order " /><br />PayPal<input name="paypal" type="radio" value="Paypal" /> </td> </tr> <tr> <td colspan = "6"> <h2> Pet Information </h2></td> </tr> <tr> <td> Name: <br /> <input name="petName" type="text" size="10" maxlength="20" /> </td> <td> Age: <br /> <select name="age"> HEREDOC; for ($age =1; $age <=20; $age ++) { print "<option value=\"age\"> $age</option>"; } echo <<<HEREDOC </select> </td> <td> Breed:<br /> <select name = "breed"> <option selected value ="Please choose a breed"/> Please choose a breed <option value = "I don't know" />I don't know <option value = "Affernpincher" />Affernpincher <option value = "Afghan Hound" />Afghan Hound <option value = "Airedale Terrier" /> Airedale Terrior <option value = "Akita" /> Akita <option value = "Alaskan Malamute" /> Alaskan Malamute <option value = "Standard American Eskimo Dog"/> Standard American Eskimo Dog <option value = "Miniature American Eskimo Dog"/>Miniature American Eskimo Dog <option value = "Toy American Eskimo Dog"/> Toy American Eskimo Dog <option value = "American Foxhound" /> American Foxhound <option value = "American Staffordshire Terrier" /> American Staffordshhire Terrier <option value = "American Water Spaniel" /> American Water Spaniel <option value = "Australian Shepherd Dog"/> Anatolian Shepherd Dog <option value = "Australian Cattle Dog"/> Australian Cattle Dog <option value = "Australian Shepherd"/> Australian Shepherd <option value = "Australian Terrier" /> Australia Terrier <option value = "Basenji" /> Basenji <option value = "Basset Hound" /> Basset Hound <option value = "Beagle" /> Beagle <option value = "Bearded Collie" /> Bearded Collie <option value = "Beauceron" /> Beauceron <option value = "Bedington Terrier"/> Bedington Terrier <option value = "Belgin Malinois"/> Belgin Malinois <option value = "Belgian Sheepdog"/> Belgian Sheepdog <option value = "Belgian Tervuren"/> Belgian Tervuren <option value = "Bernese Mountain Dog"/> Bernese Mountain Dog <option value = "Bichon Frise"/> Bichon Frise <option value = "Black and Tan Greyhound" /> Black and Tan Greyhound <option value = "Black Russian Terrier" /> Black Russian Terrier <option value = "Bloodhoung" /> Bloodhound <option value = "Border Collie" /> Border Collie <option value = "Border Terrier"/> Border Terrier <option value = "Borzoi"/> Borzoi <option value = "Boston Terrier"/> Boston Terrier <option value = "Bouvier des Flandres"/> Bouvier des Flandres <option value = "Boxer"/> Boxer <option value = "Briard"/> Briard <option value = "Brittany" /> Brittany <option value = "Brussels Griffon" /> Brussels Griffon <option value = "Bulldog" /> Bulldog <option value = "Bullmastiff" /> Bullmasttiff <option value = "Bull Terrier" /> Bull Terrier <option value = "Cairn Terrier" /> Cairn Terrier <option value = "Canaan Dog" /> Canaan Dog <option value = "Cardigan Welsh Corgi" /> Cardigan Welsh Corgi <option value = "Cavalier King Charles Spaniel" />Cavalier King Charles Spaniel <option value = "Chesepeake Bay Retriever" />Chesapeake Bay Retriever <option value = "Chilauhua" /> Chilauhua <option value = "Chinese Created" /> Chinese Crested <option value = "Chinese Shar-Pei" /> Chinese Shar-Pei <option value = "Chow Chow" /> Chow Chow <option value = "Clumber Spaniel" /> Clumber Spaniel <option value = "Cocker Spaniel" /> Cocker Spaniel <option value = "Collie" /> Collie <option value = "Curly-Coated Retrieve" /> Curly-Coated Retriever <option value = "Dachshound" /> Dachshund <option value = "Dalmation" /> Dalmation <option value = "Dandle Dimonnt" /> Dandie Dinmont Terrier <option value = "Doberman Pincher" /> Doberman Pincher <option value = "Dogue de Bordeaux" /> Dogue de Bordeaux <option value = "English Cocker Spaniel" /> English Cocker Spaniel <option value = "English Foxhound" /> English Foxhound <option value = "English Setter" /> English Setter <option value = "English Springer" /> English Springer <option value = "English Toy Spaniel" /> English Toy Spaniel <option value = "Field Spaniel" /> Field Spaniel <option value = "Finnish Spitz" /> Finnish Spitz <option value = "Flat-Coated Retriever" /> Flat-Coated Retriever <option value = "French Bulldog" /> French Bulldog <option value = "German Shepherd Dog" /> German Shepherd Dog <option value = "German Shorthaired Pointer"/>German Shorthaired Pointer <option value = "German Wirehaired Pointer" /> German Wirehaired Pointer <option value = "Giant Schnauzer" /> Giant Schnauzer <option value = "Glen of Imaal Terrier" /> Glen of Imaal Terrier <option value = "Golden Retriever" /> Golden Retriever <option value = "Gorden Setter" /> Gorden Setter <option value = "Great Dane" /> Great Dane <option value = "Greater Swiss Mountain Dog" /> Greater Swiss Mountain Dog <option value = "Great Pyrenees" /> Great Pyrenees <option value = "Greyhound" /> Greyhound <option value = "Harrier" /> Harrier <option value = "Havanese" /> Havanese <option value = "Ibizen Hound" /> Ibizen Hound <option value = "Irish Setter" /> Irish Setter <option value = "Irish Terrier" /> Irish Terrier <option value = "Irish Water Spaniel" /> Irish Water Spaniel <option value = "Irish Wolfhound" /> Irish Wolfhound <option value = "Italian Greyhound" /> Italian Greyhound <option value = "Jack Russell Terrier" /> Jack Russell Terrier <option value = "Japanese Chin" /> Japanese Chin <option value = "Keeshound" /> Keeshound <option value = "Kerry Blue TErrier" /> Kerry Blue Terrier <option value = "Komondor" /> Komondor <option value = "Kuvasz" /> Kuvasz <option value = "Labradar Retriever" /> Labrador Retriever <option value = "Lakeland Terrier" /> Lakeland Terrier <option value = "Lhasa Apso" /> Lhasa Apso <option value = "Lowchen" /> Lowchen <option value = "Maltese" /> Maltese <option value = "Standard Manchester Terrier" /> Standard Manchester Terrier <option value = "Mastiff" /> Mastiff <option value = "Miniature Bull Terrier" /> Miniature Bull Terrier <option value = "Miniature Pinche" /> Miniature Pinscher <option value = "Miniature Poodle" /> Miniature Poodle <option value = "Miniature Schnauzer" />Miniature Schnauzer <option value = "Mutt" />Mutt <option value = "Neopolitan Mastiff" />Neopolitan Mastiff <option value = "Newfoundland " /> Newfoundland <option value = "Newfolk Terrier" />Norfolk Terrier <option value = "Norwegian Elkhound" /> Norwegian Elkhound <option value = "Norwich Terrier" /> Norwich Terrier <option value = "Nova Scotia Duck Tolling Retriever" /> Nova Scotia Duck Tolling Retriever <option value = "Old English Sheepdog" />Old English Sheepdog <option value = "Otterhound" /> Otterhound <option value = "Papillon" />Papillon <option value = "Parson Russell Terrier" /> Parson Russell Terrier <option value = "Pekingese" />Pekingese <option value = "Pembroke Welsh Corgi" />Pembroke Welsh Corgi <option value = "Petit Basset Griffon Vendeen" />Petit Basset Griffon Vendeen <option value = "Pharch Hound" />Pharoh Hound <option value = "Plott" /> Plott <option value = "Pointer" /> Pointer <option value = "Polish Lowland Sheepdog" />Polish Lowland sheepdog <option value = "Pomeranian" /> Pomeranian <option value = "Portuguese Water Dog" />Portuguese Water Dog <option value = "Pug" />Pug <option value = "Pull" />Puli <option value = "Rhodesian Ridgeback" />Rhodesian Ridgeback <option value = "Rottweiler" />Rottweiler <option value = "ASaint Bernard" /> Saint Bernard <option value = "Saluki" /> Saluki <option value = "Samoyed" />Samoyed <option value = "Schipperke" />Schipperke <option value = "Scottish Doverhound" />Scottish Deerhound <option value = "Scottish Terrier" />Scottish Terrier <option value = "Sealyham Terrier" />Sealyham Terrier <option value = "Shetland Sheepdog" />Shetland Sheepdog <option value = "Shiba Inu" />Shiba Inu <option value = "Shih Tzu" />Shih Tzu <option value = "Siberian Husky" />Siberian Husky <option value = "Silky Terrier" />Silky Terrier <option value = "Skye Terrier" />Skye Terrier <option value = "Smooth Fox Terrier" />Smooth Fox Terrier <option value = "Soft Coated Wheaten Terrier" />Soft Coated wheaten Terrier <option value = "Spinone Italiano" />Spinone Italiano <option value = "Staffordshire Bull Terrier" />Staffordshire Bull Terrier <option value = "Standard Poodle" />Standard Poodle <option value = "Standard Schnauer" /> Standard Schnauzer <option value = "Suseex Spaniel" />Sussex Spaniel <option value = "Swedish Vallhound" />Swedish Vallhund <option value = "Tibertan Mastiff" />Tibetan Mastiff <option value = "Tibertan Spaniel" />Tibetan Spaniel <option value = "Tibetan Terrier" />Tibetan Terrier <option value = "Toy Fox Terrier" />Toy Fox Terrier <option value = "Toy Manchester Terrier" />Toy Manchester Terrier <option value = "Toy Poodle" />Toy Poodle <option value = "Vizela" />Vizela <option value = "Weimaraner" />Weimaraner <option value = "Welsh Springer Spaniel" />Welsh Springer Spaniel <option value = "Welsh Terrier" />Welsh Terrier <option value = "West Highland White Terrier" />West Highland White Terrier <option value = "Whippet" />Whippet <option value = "Wire Fox Terrier" />Wire Fox Terrier <option value = "Wirehaired Pointing Griffon" />Wirehaired Pointing Griffon <option value = "Yorkshire Terrier" />Yorkshire Terrier </td> </select> </tr> <tr> <td>Nutritional Needs:</td> <td><textarea name="nutritionalNeeds" cols="17" rows="5"></textarea> </td> </tr> <tr> <td>Special Instructions</td> <td><textarea name="specialInstructions" cols="17" rows="5"></textarea> </tr> <tr> <td colspan = "6"><h2>Order Information</h2></td> </tr> <tr> HEREDOC; <?php /*foreach($key as $value){ echo $value; }*/ ?> echo <<<HEREDOC </tr> <tr> <td> <input name="Submit" type="submit" value="Order Treats!" /></td><td><input name="reset" type="submit" value="Cancel Order" /> </td> </tr> </table> </form> HEREDOC; <?php } } footer(); ?> </body> </html> Hi, i'm about to start making my admin page for my site and i'm confused on if i wanted to select a user to change the password or ban them e.t.c how would i select the user?
so like if i had a list of all the users on my web page i.e
John
Paul
Lisa
how would i select one of them so i could make changes?
Hi all im trying to create a simple user registration page using php and mysql i created the database and tables locally and tested it and it works great so I did the same for on my sever and in the my mysqli connection script I changed the database name/passwords etc to match the hosting. when i tested the script I get: Notice: Constant DB_USER already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 3 Notice: Constant DB_PASSWORD already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 5 Notice: Constant DB_HOST already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 7 Notice: Constant DB_NAME already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 9 Easy to fix right. dont definine it twice. but im not defining it anywhere but my registration page and the only call i make to it is whne i use Code: [Select] require_once("mysqli_connect.php"); next mind boggling error is this: Table 'example_wrdp2.users' doesn't exist ok so to fix this I create the database right. well I have and it still dont work and I dont know why its choosing example_wrdp2 on my server i have 5 databases: example_wrdp1 example_wrdp2 example_wrdp3 example_wrdp4 example_myNewDatabase I don't understand why its not using example_myNewDatabase which i am specifying in my db connect script. Im totally lost and stuck with this. everytime i run my code i get ( ! ) Warning: mysqli_query() expects parameter 2 to be string, object given in C:\wamp\www\Tutorial\test.php on line 5. i just cant seem to find the error
my code looks like this
I am getting this error Quote Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/a6658518/public_html/view/register.php on line 83 Code: [Select] <html> <body> <pre> <?php $Fname = $_POST["Fname"]; $Lname = $_POST["Lname"]; $mail = $_POST["mail"]; if (!isset($_POST['submit'])) { ?> <form method="post" action="<?php echo $PHP_SELF;?>"> First Name:<input type="text" size="12" maxlength="12" name="Fname"><br /> Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br /> Email:<input type="text" size="12" maxlength="36" name="mail"><br /> This must be a valid email! <input type="submit" value="submit" name="submit"> </form> <? } else { if (isset($_COOKIE["dsc"])) { echo "Whoops! You already got a serial number!" } else { $myFile = $Fname; $myFile .= ".vl"; $myFile = $loca .= myFile$; if (file_exists($myFile)) { echo "We seem to have another serial key with that name already made! Please email emery.cairns@gmail.com if you think this is an error"; } else { $fh = fopen($myFile, 'w') or die("Whoops! I had an error, please contact my owner at emery.cairns@gmail.com, code: file unwriteable"); $stringData = getSerial(); fwrite($fh, $stringData); fclose($fh); echo "Hello, ".$Fname." ".$Lname.".<br />"; echo "Thanks for registering with us, the email with your serial key and name will show up in your inbox shortly!.<br />"; echo "Please make sure it does not end up in your junk mail!"; $expire=time()+60*60*24*60; setcookie("dsc", "Serial given within 60 days", $expire); $to = $mail; $serial = getSerial(); $subject = "Dhpos Self Checkout"; $message = "Hello!, your serial number for D.S.C is {$serial} and your name is {$Fname} Thanks for downloading DSC, we hope you enjoy the program. You recived this message because you requested a serial number from http://dhposselfcheckout.tk, if you did not, please disregard this message."; $from = "emery.cairns@gmail.com"; $headers = "From:" . $from; if ( $to == "emery.cairns@gmail.com" ) { echo "mail stop"; } else { mail($to,$subject,$message,$headers); } } } } ?> <br /> </pre> </body> </html> I have a MYSQL Query and when I see the code, I think it would do what I want it to do, also so do my other friends, but it doesn't. What I'm trying to do is basically make a top 10 poster, and select and order the list by the person with the most posts in the table. The table has a field named user, which represents the username. So basically I'm trying to order it by the `user` with the most posts. The problem is that it only displays the first row in the table, which is id:1. Code: [Select] SELECT * FROM `mrsw_adventurer_log` ORDER BY COUNT(`user`) I can't seem to figure it out. I want the following script to run attack_code.php when all the statements come back as being ok.. only issue is on the last line i do }else{ include("attack_code.php"); yet it runs the attack_code anyway, its rather odd as if i leave attack_code.php at the top of the page it shows the error messages of the statements below any clues? Code: [Select] <?php if($playerID == $defender) { echo "<div>You can't attack yourself.</div>"; include("exit.php"); exit; } /// below shows the noto forumla $cashnoto = round($steal_amount / 100); $drugnoto = round($steal_amount * 15); ?><br /> <?php $sql = "SELECT * FROM messages WHERE to_username = '$defender_info[username]' AND from_username = '$playerdata[username]' AND type = 'Combat' ORDER BY id DESC LIMIT 1"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $now = time(); $lastattack = strtotime($res['timestamp']); $timesince = $now - $lastattack; $nextatk = round((10800 - $timesince) / 60); if($timesince < 10800){ echo "You can only attack the same player once every 3 hours.<br><br> You can attack this player again in $nextatk minutes."; include("exit.php"); exit; }else{ $sql = "SELECT hits FROM users WHERE id = $playerID"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $hits = $res['hits']; if($hits < 1){ echo "You have no available hits. New hit allowances are granted every ten minutes on the :05's"; include("exit.php"); exit; }else{ ?> Why is this not working??? If $adsused prints out: 1, 5, 6, 7, while ($tarray=mysql_fetch_array($admintotadsq)){ $adsused .= $tarray['adnr'].', '; } $array1 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); $array2 = array($adsused); $diff = array_diff($array1, $array2); print_r($diff); print_r($diff); prints out: Array ( => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] => 16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 ) What am I doing wrong? Hey guys i have been making a site that allows people to make friends and make posts on each walls a majority is done now but when i came to do the posting on walls i have hit one cause i cant figure out the query i will need for such a pretty complex task. It works like this i have a friends table and a topics table each something like this:: member_topics << Name topic_id member_id << have one of these in every table topic_title topic_date topic_content and in the friends one:: friends_table << name id member_id << id of the person who made the friend request friend_id << id of the person accepted the friend request is_friend << if 0 friend request pending all works nice as pic however i only want to show posts to those who are friends so if i go on my profile section i will see all my friends topics and they will see mine but i cant seem to fathem out the query i have tried many ways im confused i can get it to show mine no problem. any suggestions? hope someone can help Thanks!! When I add modernizr, and I follow the tutorial he
http://webdesignerno...-use-modernizr/
I made some generic background 1 and 2 images, I set up an html file with the modernizr script in the head, before the style. You can see the page he
http://beaconfasteners.com/test.html
And the code is:
<html class="no-js"> <head> <script src="modernizr.custom.54953.js"></script> <style> #nice { background: url(background-one.png) top left repeat-x, url(background-two.png) bottom left repeat-x; } </style> </head> <body id="nice"> <p>Hello World</p> </body> </html>I pull the site up in internet explorer 11 and using the emulation tools in developer options I go down each version and view the source code. There is never a change, but the backgrounds do stop displaying. is there an extra step I am missing? Is the emulation mode not doing what I think it is? Should I setup a virtual machine with windows xp or find a windows xp system to test with? Thanks a ton! Nick Quote '31.100.x.x is not allowed to connect to this MySQL server in /home/member/insert.php on line 13 I asked a question about this a few weeks ago, and someone solved it saying that the server was blocking connections. Its confusing the hell out of me. I did as they said, and contacted my admin. they told me to fork over money, and it would be solved. I am a broke student, and dont have the cash anyway. What gets me is they said I had to be a paid member to have a sql database and connect to it with scripts on the server. But I can run a phpBB3 forum. it runs sql. I know it does. WTF? I know they are just trying to get money from me, but no matter how much I try i cant figure out how the forums connect. mine is Code: [Select] $username="a162_bento"; $password="Password123"; $database="a162_siteDB"; $localhost="host.com"; mysql_connect($localhost,$user,$password) I wish could figure out how xampp worked. If someone has time to help me I would really appreciate it. Im trying really hard but getting kick every time i get on the stage. Hi, i made a registration page in php, Only problem is its not submitting anything to the database nor throwing back an errors. I'm confused as to why, the code is below any help will be appreciated thanks ** server.php holds the database info i.e Code: [Select] <?php ///Server Info $dbhost = "localhost"; $dbuser = "*****"; $dbpass = "******"; $dbname = "****"; $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die(); mysql_select_db($dbname); ?> Registration page in question; Code: [Select] <?php require_once('check.php'); session_start(); $name = $_SESSION['name']; require_once('server.php'); require_once('stats.php'); if($_POST) { function VisitorIP() { if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $TheIp=$_SERVER['HTTP_X_FORWARDED_FOR']; else $TheIp=$_SERVER['REMOTE_ADDR']; return trim($TheIp); } $ipaddress = VisitorIP(); $name = $_POST['username']; $namelength = strlen($name); $email = $_POST['email']; $password = $_POST['password']; $passwordlength = strlen($password); $confirm = $_POST['confirm']; if($namelength < 3){ $error1="<div class='text1' style='background-color:#FF0;'><span style='color:red'>Error: Your username must be at least 3 characters!</span></div>"; echo $error1; } elseif($passwordlength < 6) { $error1="<div class='text1' style='background-color:#FF0;'><span style='color:red'>Error: Password must be at least 6 characters long!</span></div>"; echo $error1; } elseif($email == "") { $error1="<div class='text1' style='background-color:#FF0;'><span style='color:red'>Error: You must enter an email address!</span></div>"; echo $error1; } elseif($password != $confirm) { $error1="<div class='text1' style='background-color:#FF0;'><span style='color:red'>Error: Passwords do not match!</span></div>"; echo $error1; } else { include("server.php"); $query = sprintf("SELECT COUNT(id) FROM players WHERE UPPER(name) = UPPER('%s')", mysql_real_escape_string($_POST['username'])); $result = mysql_query($query); list($count) = mysql_fetch_row($result); if($count >= 1) { $error1="<div class='text1' style='background-color:#FF0;'><span style='color:red'>Error: that username is taken.</span></div>"; echo $error1; } else { $query1 = sprintf("INSERT INTO players(name,password,email,ip_address) VALUES ('%s','%s', '$email','$ipaddress');", mysql_real_escape_string($_POST['username']), mysql_real_escape_string(md5($password))); mysql_query($query1); $error1="<div class='text1' style='background-color:#FF0;'><span style='color:#390'>Congratulations, you registered successfully!</span></div>"; echo $error1; } } } ?> I make a query where I fetch som individuals and group them by class and count the rows. I make a for statement and in that statement I make a new query where I fetch all individuals in each class and sort them by id. Each member in each class should be printed into a file, limited by 15, if there is more than 15 the rest should be printed to the next file. My logic is a little confusing to me... Code: [Select] $queryorder = "SELECT * FROM mytable GROUP BY class ORDER BY cat_order"; count $rows1... for ($ii = 0; $ii < $rows1; $ii++) { $query = "SELECT * FROM mytable WHERE class = '". $rows1[$ii]['class'] . "' ORDER BY id"; $rows2 $count = 1; $sid_nr = 1; $list_nr = 1; for ($iii = 0; $iii < $rows2; $iii++) { if($count == 1) { createnewfile $ring = $rows2[$iii]['ring']; } for($count_i = 1; $count_i < 16; $count_i++): if($rows2[$iii]['C'] == 1){$rows2[$iii]['C'] = 'C';}else{$rows2[$iii]['C'] = '';} if($rows2[$iii]['S'] == 1){$rows2[$iii]['S'] = 'S';}else{$rows2[$iii]['S'] = '';} if($count_i == $count) { variabel1='VAR1'.$count_i, $rows2[$iii]['nr']); variabel2='CS'.$count_i, $rows2[$iii]['C'] . $rows2[$iii]['S']); variabel3='NAME'.$count_i, $rows2[$iii]['id_nr'] . ' ' . $rows2[$iii]['name']); } endfor; $count++; if($count == 15) { $filename = somefilename; $myFile = $resultiddir.DS.$filename; closefile $count = 1; $sid_nr++; } if($count == $rows2 { $filename = somefilename; $myFile = $resultiddir.DS.$filename; closefile $count = 1; $sid_nr = 1; } } } Some of it is pseudocode but the idea is the important thing:) Hi, Below i have some sample code and am confused over execute(), i have the code below in a try and catch block, in the catch block i call a function i created to log any error that is caught in catch block to a .txt file. I then looked online and it seems that i should do an if statement check on execute to ensure it executed the query, the part that confuses me if the execute failed i thought it would be caught in the catch block but it seems that is not the case. To explain better i have commented the code in depth on the area that i am confused about. Any help in making me understand would be great. I have not included all code above try and catch to keep things simple Code: [Select] <?php try { // connect to database $dbh = sql_con(); // checke if username exists on users table or users banlist table $stmt = $dbh->prepare(" SELECT users.user_login FROM users WHERE users.user_login = ? UNION ALL SELECT users_banlist.user_banlist FROM users_banlist WHERE users_banlist.user_banlist = ?"); // this is the part i am confused with, why is it i would use an if statement on execute() ? // i thought using a try and catch block any errors would be caught in the catch block. // using an if statement to check if execute() worked, i thought if execute failed it would // be handled by the catch block, i mean in my exmaple code here, what could cause the execute to fail ? // and why if execute failed it would not be caught by catch block ? // i am looing at exmaple online and i am reading different things and its all confusing me // execute query if(!$stmt->execute(array($username, $username))){ echo 'something went wrong .. '; } else { // execute worked } } // if any errors found log them in my ExceptionErrorHandler() function and display friendly message catch (PDOException $e) { // this function catches an error and logs them to file ExceptionErrorHandler($e); require_once($footer_inc); exit; } } ?> Thanks or any help! |