You are here: Re: php variable in sql string « PHP Programming Language « IT news, forums, messages
Re: php variable in sql string

Posted by Carl Pearson on 01/17/07 17:31

user wrote:
> Have require file with several query stings in it.
>
> Depending on user input one of strings is selected. Everything going
> along smoothly until I wanted to also input a variable in string. If I
> put string in program works ok, but, if I use string from require file I
> can not seem to insert string.
>
> $cccb_id is sting..... to be inserted into $query4 and changes depending
> on user input.
>
> $query4 = "select cccb.cccb_name as 'cccb', CONCAT(member_fname,'
> ',member_lname) as 'member' from member_cccb_lnk join member on
> (member.member_no = member_cccb_lnk.member_no) join cccb on
> member_cccb_lnk.cccb_id = cccb.cccb_id and cccb.cccb_id = "$cccb_id"
> order by member";
>
> output is: select cccb.cccb_name as 'cccb', CONCAT(member_fname,'
> ',member_lname) as 'member' from member_cccb_lnk join member on
> (member.member_no = member_cccb_lnk.member_no) join cccb on
> member_cccb_lnk.cccb_id = cccb.cccb_id and cccb.cccb_id = order by
> memberError 1064
>
> as you can see, "$cccb_id" is not in query string.
>
> any help will be appreciated.

You need to concatenate, i.e.
$query4 = "some stuff " . $cccb . " some more stuff";

Make sure you allow for adequate spacing where the different parts meet,
as the concatenation will literally attach whatever you put together
into one new string.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация