Buy Sell Discuss UK Domain Names at AcornDomains.co.uk

Today's Drop Dates are: 19-02-2012 or 26-02-2012   All times are GMT. The time now is 03:38:12 AM.
Domain Name Sales Domain Software Calculate UK Domain Drop Dates Domain Registration NameDrive Domain Parking Subscribe to our Domains For Sale newsletter
Go Back   Domain Forum Acorn Domains Buy Sell Auction UK Domains > General and Domain News > General Board
Connect with Facebook

General Board General discussions. Please check main forum categories before posting here.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 04-03-2008, 09:21:52 AM     #1 (permalink)

 
Join Date: Sep 2006
Posts: 406
purg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond repute

Question PHP variable help

I posted here because this isnt strictly a web design problem but hoping you can help (or point me in the right direction).

Im writting a PHP script to display data on a userbar which works

PHP Code:
$userbar_text "Checked : 1 $xa of $x work";
imagestring($im$font125,    3$userbar_text$colour); 
The problem is that im wanting to move $userbar_text into a config file but cant get embedded $xa of $x to parse correctly.

So the above in short has become:-
config.inc.php
PHP Code:
$rsdata = array(
//        id        img        cl1    cl2    cl3    fnt    x        y    "text"
array(    "001",    "001",    0,    0,    0,    3,    125,    3,    "Checked : 1 \$xa of \$x work"),
array(    
"002",    "002",    0,    0,    0,    3,    125,    3,    "Checked : 2 \$xa of \$x work"),
array(    
"003",    "003",    0,    0,    0,    3,    125,    3,    "Checked : 3 \$xa of \$x work"),
); 
script.php
PHP Code:
require_once('includes/config.inc.php');
...
...
foreach (
$rsdata as $i => $tempvalue) {
    if (
$imgnum == $rsdata[$i][0]) {
    
$userbar_text $tempvalue[8];
    
$colour imagecolorallocate($im$tempvalue[2], $tempvalue[3], $tempvalue[4]);
    
ImageFill($im00$grey);
    
imagestring($im$tempvalue[5], $tempvalue[6], $tempvalue[7], $userbar_text$colour);
    }


but whatever I try, userbar displays either the text "Checked : 3 $xa of $x work" without changing $xa or $x or "Checked : 3 of work" with the variables being blank.
purg is offline  
Old 04-03-2008, 10:24:31 AM     #2 (permalink)
Member
 
Join Date: Apr 2007
Location: Edinburgh
Posts: 44
etro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond reputeetro has a reputation beyond repute

I'm not a php programmer, but I can't see where you are declaring what vars $x and $xa?

I'm guessing that $xa should be your $rsdata array length?
And $x is your current position in the array?
etro is offline  
Old 04-03-2008, 11:22:06 AM     #3 (permalink)

 
tifosi's Avatar
 
Join Date: Oct 2004
Location: Lancashire
Posts: 1,907
tifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond reputetifosi has a reputation beyond repute

I get the impression this isn't the whole script.

As above $xa $ x aren't set, and when you split the array arrays into key value pairs where is imgnum set for the comparision with 001, 002 etc?

S
tifosi is offline  
Old 04-03-2008, 01:22:56 PM     #4 (permalink)

 
Join Date: Sep 2006
Posts: 406
purg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond repute

Yea thats far from the whole script as its a project in the making, but this might make it easier.

PHP Code:
require_once('includes/config.inc.php');
$xa "apple";
$x "plum";
echo 
$tempvalue[3][8]; 
Im wanting the script to output "Checked : 3 apple of plum work"
ive highlighted the vars taken from config.inc.php with $x $xa being substituted.


In the example posted $tempvalue[3][8] is the same but obviously this changes place and wording allowing the user to config the output.
purg is offline  
Old 04-03-2008, 02:30:21 PM     #5 (permalink)

 
Join Date: Sep 2006
Posts: 406
purg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond repute

After posting I reading some of your comments I googled for "replace" and came up with a answer to my problem.

preg_replace
^ ive not see this before but does the job

config now looks like this
PHP Code:
$rsdata = array(
//        id        img        cl1    cl2    cl3    fnt    x        y    "text"
array(    "001",    "001",    0,    0,    0,    3,    125,    3,    "Checked : 1 #xa# of #x# work"),
array(    
"002",    "002",    0,    0,    0,    3,    125,    3,    "Checked : 2 #xa# of #x# work"),
array(    
"003",    "003",    0,    0,    0,    3,    125,    3,    "Checked : 3 #xa# of #x# work"),
); 
and the script using preg_replace
PHP Code:
foreach ($rsdata as $i => $tempvalue) {
    if (
$check_user == $rsdata[$i][0]) {
    
$imgnum $tempvalue[1];
    }
    if (
$imgnum == $rsdata[$i][0]) {
    
$userbar_text preg_replace("/#xa#/"$xa$tempvalue[8]);
    
$userbar_text preg_replace("/#x#/"$x$userbar_text);
    
$colour imagecolorallocate($im$tempvalue[2], $tempvalue[3], $tempvalue[4]);
    
ImageFill($im00$grey);
    
imagestring($im$tempvalue[5], $tempvalue[6], $tempvalue[7], $userbar_text$colour);
    }


Thanks for your comments, from this I was able to find an answer via google.
purg is offline  
Closed Thread



Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Domain Name Community Replies Last Post
PHP Builder admin Scripts and Coding 1 02-12-2007 08:18:08 AM
PHP help admin Scripts and Coding 0 17-11-2007 03:11:05 PM
PHP Link Directory - Free Templates admin Website Design 0 18-05-2006 12:25:17 PM

Web Hosting from UK2 from just 99p


All times are GMT. The time now is 03:38:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0 RC 2
All content on Acorn Domains is member generated and is not moderated before posting. All content is viewed and used by you at your own risk and AD does not warrant the accuracy or reliability of any of the information. The views expressed are those of the individual contributors and not necessarily those of AD. Please contact us to report any issues or send a PM to "Admin".