Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Using PHP variables in mysql DB fields
Old 11-01-2008, 06:04 PM Using PHP variables in mysql DB fields
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
Hi everyone,

i want to store php variables in db fields.

IE
$ct = "happy campaign";

// query db result
fieldA = Thanks for getting involved. Your campaign ".$ct. " has been

$body = $fieldA;

echo $body;

result rendered = Thanks for getting involved. Your campaign ".$ct. " has been

The problem i am having is when i collect the field content, even though $ct is defined before the query, $ct is what is stored to the variable and not the previously defined va;ue stored in $ct.

Could anyone help me this?

The result i want to get is

Thanks for getting involved. Your campaign happy campaign has been


Cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 11-02-2008, 09:17 AM Re: Using PHP variables in mysql DB fields
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Code:
$ct = "happy campaign";

// query db result
fieldA = "Thanks for getting involved. Your campaign ".$ct. " has been"

$body = $fieldA;

echo $body;
You want the hardcoded strings (i.e. Thanks for getting...etc) to be within quotes and the variables to be concatenated to the string with the dot (.) notation e.g.

Code:
$var1 = "that will be";
$var2 = "rendered on my page.";

$string = "this is a string " . $var1 . "concatenated and " . $var2;

print $string; //will output: "this is a string that will be concatenated and rendered on my page
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 11-04-2008, 12:49 AM Re: Using PHP variables in mysql DB fields
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Oh, wheel inventors...

sprintf()
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Using PHP variables in mysql DB fields
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43723 seconds with 12 queries