Skip to main content
Inspiring
January 15, 2008
Question

variables.searchphrasepq undefined

  • January 15, 2008
  • 1 reply
  • 318 views
Hi all I`ve been working on this for a while now and it has been useful to understand lists and list functions. The following code gets whatever keywords there are on the right(listlast really) of the = delimiter. This works fine for google but no I tried to add a new condition as other search engines use ?p= or ?q= to define string so a string like http://search.msn.com?p=keywords+keywords&int&=N it will get the first in the list after the ?p= not N if that makes sense. I thought I was getting there defining if the string has <cfset findq=find("[p=]|[q=]", qrysales.referer)>
Really I just need a hand please and a push in the right direction-not code just a nod as to what I need to do! Thanks
<table width="792">
<tr>
<td>
<div align="center">
<a href="searchengines.cfm?sortBy=visit">Date</a>
</div>
</td>
<td> <div align="center">
<a href="searchengines.cfm?sortBy=id">Visit No.</a>
</div>
</td>
<td> <div align="center">
<a href="searchengines.cfm?sortBy=id">Search Engine</a>
</div></td>
<td> <div align="center">
<a href="searchengines.cfm?sortBy=referer">Keywords (click on record to see full query)</a>
</div>
</td>
</tr>


<!--- output the all the rows in the query qrysales --->
<cfoutput query="qrysales" startrow="#nav.startrow#" maxrows="#nav.maxrows#">

<cfset strStart = find("?", qrysales.Referer)>

<cfset referer_queryString = right(qrysales.Referer,len(qrysales.Referer)-strStart)>

<cfset findq=find("[p=]|[q=]", qrysales.referer)>
<cfset referer_findq = left(qrysales.Referer,len(qrysales.Referer)-findq)>
<cfif find("[p=]|[q=]", referer_findq)>
<cfset searchPhrasepq = listfirst(referer_findq,"=")>
</cfif>

<cfloop list="referer_querystring" delimiters="%" index="i" >

<cfset variables.searchPhrase1 = listlast(referer_findq,"=")>

<!---then we get rid of all the searchphrase1 rubbish chars--->
<cfset googlewords=#replacelist(variables.searchphrase1,"+,/,=,%,http:, 3Fq3,'=es',terms,search,query,qkw,2B,&meta,3Fq,3D,2D,2522,26start,26svnum,600,46947,SZIR,wl,[%20],26st",", , , , , , , , ")#>

<tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#">
<td>#qrysales.visit#</td>
<td>#qrySales.id#</td>
<td> <cfif find("google.it", qrysales.referer)>
Google Italy
<cfelseif find("google", qrysales.referer)>
Google
<cfelseif find("msn", qrysales.referer) or find("live.com", qrysales.referer)>
MSN Live
<cfelseif find("yahoo", qrysales.referer)>
Yahoo
<cfelseif qrysales.referer does not contain "google" or qrysales.referer does not contain "yahoo"
or qrysales.referer does not contain "msn">
Other search engine
</cfif></td>
<td>
<cfif len(googlewords) is 0>
hey#qrysales.referer#
<cfelseif len(googlewords) and find("N", "#googlewords#")>
<cfset innitnow=find("N", "#googlewords#")>
#variables.searchphrasepq# n found

<cfelse>

<a href="keywords.cfm?id=#qrysales.id#">#len(googlewords)# #googlewords#</a>

</cfif>
</tr>
</cfloop>
</cfoutput>

</table>
This topic has been closed for replies.

1 reply

January 15, 2008
I could be wrong, but I don't believe http://search.msn.com?p=keywords+keywords&int&=N contains a valid query string. Also, <cfset findq=find("[p=]|[q=]", qrysales.referer)> is not going to do a regular expression find - for that you want <cfset findq=ReFind("[p=]|[q=]", qrysales.referer)>
Inspiring
January 17, 2008
Thanks for the reply appreciated. I have got rid of a lot of the code which makes thing s lot easier to understand, what I am trying to do is is the string has the string ?p= or ?q= then do something with them and if not then output googlewords. I can´t seem to be able to get that to work-no errors however-does the ? char cause problems? TIA

<cfparam name="url.sortBy" default="id">

<cfquery name="qrysales">
SELECT Referer, visit, id
FROM clientinfo
where Referer <> "Outside webpage:unknown"
order by #url.sortBy#
</cfquery>


<cfoutput query="qrysales">

<cfset strstartp=ReFindnocase("[?q=]|[?p=]", qrysales.Referer)>
<cfset referer_find2 = left(qrysales.Referer,len(qrysales.Referer))>


<cfset referer_findq = left(qrysales.Referer,len(qrysales.Referer))>

<cfset variables.searchPhrase1 = listlast(referer_findq,"=")>


<!---then we get rid of all the searchphrase1 rubbish chars--->
<cfset googlewords=#replacelist(variables.searchphrase1,"+,/,=,%,http:,

3Fq3,'=es',terms,search,query,qkw,2B,&meta,3Fq,3D,2D,2522,26start,26svnum,600,46947,SZIR,wl,[%20],26st",", , , , , , , , ")#>


<cfset variables.searchPhrase2 = listlast(referer_find2,"?=")>

<cfif len(googlewords) is 0>
#variables.searchphrase2#<br>
<cfelse>
<a href="keywords.cfm?id=#qrysales.id#">#googlewords#</a><br>
#variables.searchphrase2#<br>
</cfif>

</cfoutput>