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
Variable in MySQL statement
Old 11-14-2007, 05:07 PM Variable in MySQL statement
melefire's Avatar
Experienced Talker

Posts: 46
Name: matt
Trades: 0
PHP Code:
$sql 'ALTER TABLE `$dbprefixuser` ADD `test` CHAR(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL;'
I am trying to get this to work, i need to have the variable $dbprefix inserted right before the word "user". Please help


thanks
melefire is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-14-2007, 05:22 PM Re: Variable in MySQL statement
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Use the . operator to concatenate strings:

PHP Code:
$sql 'ALTER TABLE `'$dbprefix 'user` ADD `test` CHAR(1)...'
__________________

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
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-14-2007, 05:51 PM Re: Variable in MySQL statement
melefire's Avatar
Experienced Talker

Posts: 46
Name: matt
Trades: 0
thanks
melefire is offline
Reply With Quote
View Public Profile
 
Old 11-15-2007, 08:07 PM Re: Variable in MySQL statement
melefire's Avatar
Experienced Talker

Posts: 46
Name: matt
Trades: 0
i am trying to do the same in another statement, but i just get error: table does not exist, here is my code:
PHP Code:
$query="SELECT * FROM `'. $dbprefix . 'user` WHERE user_name='$search';"
melefire is offline
Reply With Quote
View Public Profile
 
Old 11-16-2007, 01:30 AM Re: Variable in MySQL statement
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
It's your quotes. Try this:

PHP Code:
$query='SELECT * FROM `'$dbprefix 'user` WHERE user_name='$search';'
__________________

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
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Variable in MySQL statement
 

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.14718 seconds with 12 queries