Request.ServerVariables in classic Asp [duplicate] - asp-classic

This question already has answers here:
How to get the referer search query from google?
(4 answers)
Closed 3 years ago.
I have this requirement: I need to save the search word made by a user who has come to my site.
The site is made in classic asp.
I have tried with:
Request.ServerVariables ("HTTP_REFERER")
Request.ServerVariables ("ALL_HTTP")
But I don't get the search query (q=) https://www.google.com/search?q=house
How can I get the value of q= ?

The following code will give you what you are looking for:
Response.Write(Split(Split(Request.ServerVariables ("HTTP_REFERER"), "?")(1),"=")(1))
For sure, you will need to adapt it : if you don't have query string, it will fail, and the parameter you are looking for needs to be the first one.

Related

Firebase: If a value includes a specific text in database [duplicate]

This question already has answers here:
How to perform sql "LIKE" operation on firebase?
(5 answers)
Closed 3 years ago.
I try to filter the list for items that contain a certain text.
database:
{"123":{"cities":"sss"},"445":{"cities":"hello hi dd"}}
And I want to get the items that contains "hi" within the cities value:
{"445":{"cities":"hello hi dd"}}
I tryd this:
https://xxxxx.firebaseio.com/allitems.json?orderBy="cities"&startAt="hi"
But it's not working... It only shows the items that starts with "hi"...
thanks.
At the time of writing, there is no built-in full-text search capability in the Firebase Realtime Database.
The official Cloud Functions samples include an example of full-text search with the Algolia hosted search service.
Note that there is a workaround if you search for a string that starts with some specific characters (which is different than a string which contains some specific characters).
Have a look at the "Range Queries" section of the REST API documentation:
We can combine startAt and endAt to limit both ends of our query. The
following example finds all dinosaurs whose name starts with the
letter "b":
curl
'https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy="$key"&startAt="b"&endAt="b\uf8ff"&print=pretty'
The \uf8ff character used in the query above is a very high code point
in the Unicode range. Because it is after most regular characters in
Unicode, the query matches all values that start with a b.
So in your case you would do as follows:
https://xxxxx.firebaseio.com/allitems.json?orderBy="cities"&startAt="hi"&endAt="hi\uf8ff"

Show data in webpage from database [duplicate]

This question already has answers here:
Generate an HTML Response in a Java Servlet
(3 answers)
Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern
(6 answers)
Closed 2 years ago.
Suppose, I have updated my database by which I mean that I have inserted a new row of data in my database. Now, I want to edit my web page by that data how can I do this?
Suppose, I have three columns in my database "name", "picture" and "age" now I want to show the latest row of these columns in my HTML page with CSS applied. How can I do this please tell me the codes in terms of JSP and servlet.
First get that value in your servlets from database and then to show it in webpage
You can do two things :
Use request.setAttribute("id",value)
In the GET method of servlet,
request.setAttribute("name",value)
request.setAttribute("picture",value)
request.setAttribute("age",value)
And in the jsp, you can get these values as
request.getAttribute("name")
request.getAttribute("picture")
request.getAttribute("age")
Model
model.addAttriute("name",value)
Use JSTL library and then you get these values in jsp by:
${name}
${picture}
${age}

Firebase "like" search on string [duplicate]

This question already has answers here:
How to perform sql "LIKE" operation on firebase?
(5 answers)
Closed 5 years ago.
I am trying to search the user on the basis of name . It search perfectly if the name is given from first name but didn't search on the string the second name. Where first and second both are saved in one value separated by space for example
"John Smith". If search on "john" or "jo" etc it retrieve the record but if its smith it retrieve nothing.
Code
var ref = firebase.database().ref().child('User').orderByChild("name").startAt(searchString).endAt(searchString + "\uf8ff");
$scope.usercollection = $firebaseArray(ref);
With your query it is normal that you only get results starting with j, jo, joh, john, etc... The startAt method "creates a Query with the specified starting point". So it looks at how your searchString variable starts.
There is no full text search mechanism in Firebse for the moment. You will find on the web several possibilities to implement such a mechanism, e.g.:
https://firebase.googleblog.com/2014/01/queries-part-2-advanced-searches-with.html
https://github.com/FirebaseExtended/flashlight

ASP.NET Passing Inconsistent DateTime Format to SQL Server [duplicate]

This question already has answers here:
RDLC - "String Not Recognized As A Valid DateTime" Error
(2 answers)
Closed 2 years ago.
I know this is an age-old question but I'm not exactly new to it and I haven't found an answer which helps me so far!
I've got an ASP.NET site which displays data from an SQL Server 2005 database. At the top of the page are 'Date From' and 'Date To' textboxes which are used to filter the data shown beneath.
The data is displayed using an SqlDataSource, and the two dates are passed as parameters to a Stored Procedure. The textboxes display the dates and accept input in UK date format (dd/MM/yyyy) and it works fine.
Now I've added a new page with exactly the same setup, displaying slightly different data. In the backend I created a new Stored Procedure by copying and pasting my original one, it's almost identical. And yet on this page I get errors with my dates because they're being read as MM/dd/yyyy, meaning that today's date, for example, 15th August 2011, is passed as 15/08/2011 and isn't a valid date.
I've checked over everything and I can't understand why this should work on one page and not another, especially when I've basically just copied all of the original code and tweaked it slightly. Can anyone suggest anything I can check that I might not have thought of?
The text boxes are strings, which are in the thread local which is set from the browser (langauges).
Convert them to aa DateTime object first, using a local aware transformation, then write the dateTime object to the server. NEVER (!) deal with strings to sql server unless you format them in ISO independent form (2011-08-17 23:52:11).
But in general, ASp.NET will show dates, times, numbers in the local langauge of the browser. Either turn that off, or deal with it. It is nice for the user. So, check locales - user, server process. What is the thread current locale?
You need to use the SQL convert in stored procedure like:
convert(varchar, #yourdateParameter, 103) for format dd/mm/yyyy
or
convert(varchar, #yourdateParameter, 101) for format mm/dd/yyyy
Hope this helps.

simple question on asp net profile

i believe this is a simple question but i can't figure out myself. In the aspnet profile there is propertynames column with value [value]::: (e.g. OfficeKey:S:0:1:)
Does anyone know what the ":S:0:1:" is? How can I read it?
thanks
It means it's a String, which starts at position 0 in the PropertyValuesString field, and is 1 character long.
Have a read of http://pretzelsteelersfan.blogspot.com/2007/03/get-aspnet-profile-properties-from-sql.html if you want to do your own manipulation of the fields in SQL.

Resources