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
Old 03-04-2008, 04:34 AM str_replace variable
Skilled Talker

Posts: 72
Trades: 0
Hi,

Can someone help me? I created this script

PHP Code:
opendb();
$q "select barang, warna from table1" where barang='meja'"; 
$r = querydb($q);
$d = mysql_fetch_array($r);

$q2 = "select barangwarnahargajumlah  from table2 where where barang='{barang}' and warna='{warna}'"; 

$before = array("{", "}");
$after  = array("\$d2['", "']");

$q2 = str_replace($before$after$child_query);
$r2 = querydb($q2);
$d2 = mysql_fetch_array($r2); 
After str_replace { } this would be $d2['barang'] and $d2['warna'] and the content will follow the first query ($q). But the problem the script could not run well. The varible won't get form $q

Can some one help me?

Thanks
__________________

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
jaketmerah is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-04-2008, 07:10 AM Re: str_replace variable
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
PHP Code:
$q2 "select barang, warna, harga, jumlah  from table2 where barang='{$d['barang']}' and warna='{$d['warna']}'"
__________________

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!
 
Old 03-05-2008, 12:35 AM Re: str_replace variable
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
First this line:
PHP Code:
$q "select barang, warna from table1" where barang='meja'"; 
remove the " after table1. Now this line:
PHP Code:
$q2 "select barang, warna, harga, jumlah  from table2 where where barang='{barang}' and warna='{warna}'"
Never actually gets used, $q2 gets replaced later on with:
PHP Code:
$q2 str_replace($before$after$child_query); 
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to str_replace variable
 

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