Random Quote From A Database Every 4 Days
obviously in standard asp. and i'm not even sure where to begin. I currently have it set up for a random quote every time a user refreshes the site. This was no problem. Any help or if you can point me in the right direction.
View Replies
ADVERTISEMENT
does exist any command to get random row from target table in target database and then use this row ?
View Replies
View Related
I am using the following code to Query information from my db table. The problem I have is that it displays the whole table rather than displaying 5 random results by ProductID.
<%
objConn2.open strconn2
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open "SELECT * FROM Products", objConn2
Do While Not objRS2.EOF
Response.Write ":: <a href=""productsDisplay.asp?ProductID=" & objRS2("ProductID") & """>" & objRS2("Product_Description") & "</a><br>"
objRS2.MoveNext
Loop
objRS2.Close
objConn2.Close
Set objConn2 = Nothing
%>
View Replies
View Related
I'm trying to create a portion of script that would select x (variable) number of random records from a table.
in PHP, I could do this pretty simply with a line like, "select * from table order by rand() limit x", but the solutions I've seen so far for asp and access involve things like 40 lines of code, selecting the entire contents of a database, creating temporary tables, etc.
Is there any quick and dirty way of doing this?
View Replies
View Related
Suppose I have a table named as tblfriends and there are 3 columns with several row. Column names are: name, email, phone
I want to pick 5 names randomly from the table each time my asp page refreshes. How can this be coded in classic asp?
View Replies
View Related
I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program generating the 327 passwords, but have had no luck inserting them. Code:
View Replies
View Related
ill have a database with 1 table and 3 fields:
ID FIRSTNAME LASTNAME
(the ID field will be the auto incrementing index)
there might be 10 records in the DB, there might be 10,000. i need to open the DB and randomly select a record (and then display the name, which i dont have a problem with)
how can i randomly select a record? im guessing id have to open a recordset and check the count to get the number of records, so lets say there were 100 records. i imagine i would have to generate a random number between 1 and 100....
View Replies
View Related
I am trying to write a script that generate random code which are not in database.
Things are ok on these points:
1. Generating a random code
2. Controlling whether it is in database.
For now, if the code is in database, it gives a message.
What I want the funstion do is to generate a code which is not in db?
How can id do this?
I write the code as reference.....
View Replies
View Related
The following code should select the specified number of records randomly from the database .....
View Replies
View Related
There are 26 prizes available in a competition a client is running and he wants to be able to select these at random.
I thought the best way of doing this would be to construct a simple ASP page which displays 26 random records from the database.
The fields I wish to display are called name, email and address, and these are located in the table called Competition (this is an MS Access db).
View Replies
View Related
I am trying to retrieve images from the database and display them in a random order. The order of the images is supposed to change each time page is refreshed.
Below is my code, I am using an array to store the images but the images are not displayed for some reason. Any help would be appreciated.
<% Dim rstResult
Dim strSQL
Dim img(100)
imgID = 0
set rstResult = Server.CreateObject("ADODB.Recordset")
strSQL = "sp_sel_TilesByType 'O'"
rstResult.Open strSQL, strConnect
set rResult = Server.CreateObject("ADODB.Recordset")
sSQL = "sp_sel_TilesByType 'O'"
rResult.Open sSQL, strConnect
if not rResult.EOF then
do while not rResult.EOF
response.write("hi")
imgID = imgID + 1
img(imgID) = "images/tiles/" & rResult("TileImage")
response.write(img(imgID))
rResult.movenext
loop
end if
if not rstResult.EOF then
intVendorID = 0
do while not rstResult.EOF
if intVendorID <> rstResult("VendorID") then
rndNumber = RandomNumber(imgID)
Response.Write "<p>"
Response.Write "<a href=javascript:popWin('tileview.asp?" & rstResult("TileID") & "','',1,1,1,1,700,600);>"
'Response.Write "<img src=images/tiles/" & rstResult("TileImage") & " border=0>"
response.write(rndnumber)
Response.write "<img src=img(rndNumber)>"
Response.Write "</a>"
Response.Write "</p>"
end if
intVendorID = rstResult("VendorID")
rstResult.MoveNext
loop
end if
set rstResult = nothing%>
View Replies
View Related
I am trying to write an array of random numbers to a database. The array part is working fine, but when I go to update the dataabse, it inserts the last value of the array into all the fields in the database .....
Dim MyValue,sqlRandom
Dim arrayRandom(8)
for i = 1 to 8
Randomize
MyValue = Int((100 * Rnd) + 1)
arrayRandom(i) = MyValue
response.write "<p> Array Value:" & arrayRandom(i)
sqlRandom = "UPDATE CarParkDetails SET FreeSpaces = '" & arrayRandom(i) & "'"
Conn.execute(sqlRandom)
next
I can't see whats wrong!
View Replies
View Related
However, what I want to do is include a request.querystring("ID"), so that IF an ID is defined, eg ID=3, , it will display the relevant (not random) information. I've tried this every way I can think and get type mismatches, etc etc. It's probably really simple but I can't see it.
<%
limit=3
redim link(limit)
redim image (limit)
link(1)="xxx"
image(1)="image1.jpg"
link(2)="xxx"
image(2)="image2.jpg"
link(3)="xxx"
image(3)="image3.jpg"
randomize
random=int(rnd*limit)+1
%>
<center>
<a href="<%= link(random) %>">
<img src="<%= image(random) %>" border="0"></a>
View Replies
View Related
I just wanted to know whats the best way to generate 50 or say X amount of number at random without having to repeat any of the previous number...
so far I've the following:
[VBS]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
function RandomNumber()
dim theRandom
Randomize
'RandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
theRandom= Int((99 - (0) + 1) * Rnd + (0))
if (theRandom<10) then theRandom = "0" & theRandom
RandomNumber = theRandom
end function
%>[/VBS]
and then I've this in the body of HTML doc: Code:
View Replies
View Related
We have the need to have a random token (a 16 char alphanumeric field) to be used as the key for one of our SQL tables. I have created a random token generator, however after only 3 months in production, it appears that we had an instance where a token that already existed in the tables was created. There are 3810 records currently in the database so it isn't like there are billions of records there.
I contacted an old college buddy of mine who is a mathematician, and he claims, assuming that random really does mean random, that the chances of getting a duplicate token are 1 in 79.5 septillion (79,500,000,000,000,000,000,000,000).
So my conclusion is that this was either a complete freak of nature occurance, or my random generator isn't really all that random. Here is the code behind how I am generating this: Code:
View Replies
View Related
I have a simple form submission but the problem is my SQL insert (or update) is failing if in the text field there is any single quotes (')
I tried running the like replace(textfield,"'","") to just remove them but it will still error out on me.
is there any other way to format the variable, do I need to use an escape character?
View Replies
View Related
Is it possible to grab stock quotes (with of course the 15min delay!!) and place within an ASP page?written in ASP.it is possible to read HTML content on webpages without outputting them and then using the values etc
View Replies
View Related
I'm trying to make a dynamic table where on the left side items are placed and on the right side the item clicked is shown. For an example look at www.uitdagen.nl uitgaan->cafes
This all works fine except when I use a ' or a newline a error is generated because in dhtml a ' is used to open and close a string. When i use a ' in the string it goes wrong because i already close the string in the string.
If already tried to use chr(39) etc. But this won't work because this still will generate a ' for the dhtml.
View Replies
View Related
Running into a what I thought should be a small problem but it's going on an hour and I still can't figure it out
Reading an excel file and running queries on Sheet names. The problem is when there is a single quote in the sheet name.
selectQuery = "SELECT * FROM Dave's Sheet"
I tried to use
selectQuery = "SELECT * FROM Dave's Sheet"
But that doesn't work either.
It keeps bombing the query. Not matter what I try I can't get this to work. I can't replace the single quotes because then it can't find the tab name. Any ideas?
View Replies
View Related
how i could insert data into my DB that contained apostrophes. for example, I wanted to insert Bailey's well, my SQL statement was being cut off when it hit the ' and i was getting all sorts of errors. i was writting some complex stuff to take out the ' then re-insert it when being displayed.lots of work then i thought, what if i replace my ' with " in my insert statement.
like i said, some of you may know this, but i thought id share my experience with you just in case someone runs across the same problem.
View Replies
View Related
I am writing an asp app for generating quotes. What I would like to do is allow the user to edit the quote lines without having to open a new page each line.
On the quote I have created a loop which goes through the recordset and populates a sort of data grid. Can you use javascript or something so the user can click an edit icon on the appropriate line item in the grid and edit the line details there instead of having to open another page to edit the line item.
View Replies
View Related
I have this simple Select:
Select * from MATABLE WHERE title = '"&myvariable&"' ORDER BY title
so some of my title have single quote/apostrophe in them, ex: Don't know me . so when I tried to access those article with that kind of title I get the error message Missing operator. So is there a way to have my title be all right? a function maybe?
View Replies
View Related
I am having a problem with a single quote in my URL. I use HTMLEncode and all is good on my machine, but when I test it with a browser from a different machine, I get 403 on invalid characters. More, it seems to me that the URL gets truncated after that single quote that I have in my URL.
View Replies
View Related
I am working on building an asp forum, (I have posted a few times with questions ) and it works for the most part now, but I am trying to fix some things.
I am storing posts in a memo field. Originally it was text fields, but 255 characters is just not good enough.
Now, posts are saved fine except for 2 things:
1/ " and ' cause errors. These are causing conflicts with my INSERT SQL statement that is made. How would you get around this problem, I wonder?
2/ New lines etc are not being put into the memi field. I can live without this for the time being, but at some point I will want to implement posts being outputted in the same format they were inputted. Any advice on how to deal with this issue?
View Replies
View Related
I am having trouble getting the 's and +s on this statement correct. The first select line works as it is supposed to but the 2nd one does not. Can anyone correct this and perhaps tell me/point me in the direction of the rule of thumb for stuff like this?
Code:
<SELECT size="1" name="waste" onChange="window.location='drumsnew.asp?waste='+this.value+' &c_type=<%=Selected_Container_Type%>'+'&c_size=<%=Selected_Container_Size%>';">
<SELECT size="1" name="ctype" onChange="window.location='drumsnew.asp?waste='<%Selected_Waste_Type%>'+'&c_type='+this.value+'&c_size=<%
=Selected_Container_Size%>';">
View Replies
View Related
I'm trying to produce an image with a javascript link. The problem seems to
be with the single quote. Here is the code that I wrote:
response.Write("<a href='javascript:PopUp('http://www.yahoo.com')'><img src='image1.jpg' width='50' height='67'></a>")
When I preview the page and roll over the image, the link is truncated to just javascript:PopUp( .
I've tried creating the link with a string like below.
strLink = "javascript:PopUp(" & " ' " & "http://www.yahoo.com" & " ' " & ")"
The string displayed properly when printed on screen, but when I tried to use it as the link it truncated again. I'm not real sure what to try next.
View Replies
View Related
I seem to end up with too many double quotes when using this clean up function.. either that or I am missing a display function when I display the details from the dB.
My function
Code:
Function CleanFormFields(FieldString)
FieldString = Replace(FieldString, "�", "'")
FieldString = Replace(FieldString, "�", """""")
FieldString = Replace(FieldString, "�", """""")
FieldString = Replace(FieldString,"""","""""")
FieldString = Replace(FieldString, "'", "''")
FieldString = Trim(FieldString)
CleanFormFields = FieldString
End Function
I only really wanted the microsoft ouble quote to become one set of double quote instead of double as I have here but I can't get away with anything less.
essentially when I input a � I get a "" when I only want ".
View Replies
View Related
I have a rather basic question. I have a simple username and password front end that queries a SQL database, I run into problems when one of the user names has a single quote in it (IE: O'brian).
I get the "Microsoft OLE DB Provider for SQL Server error '80040e14' Line 1: Incorrect syntax near 'brian'." error message, any clues on how to display those particular cases? is there anything in particular that should be done to my SQL statement?
View Replies
View Related
I have a code that goes to the url of the company.My problem is that if a company name has a single quote in it,it tries to end the statement.I tried a replace as you will see,but still doesn't work.Heres my code:
Response.Write "<td><center><a href='edit.asp?company="
Response.Write server.URLEncode(replace(rs("Company"),"'","'"))
Response.Write "'>Edit</a></center></td>"
View Replies
View Related
If rs("MyString") is Hello "Jim" Lad
<input type=text value="<%=rs("MyString")%>">
prints as <input type=text value=" Hello "Jim" Lad">
How can I get double quotes to display in a text box or textarea? Using a backslash or &Quot; (with Replace() e.g.) just prints out the backslash or &Quot;
View Replies
View Related
i want to place single quote in customer name. how?
View Replies
View Related
Here's the line I need to insert into an ASP page.
<script Language="JavaScript" src="/blarg.js"></script></head>
Right now it throws off the asp include with the quotes.
View Replies
View Related