Starting with 17th May 2007, Adobe Systems will stop offering support for any version of the discontinued InterAKT products. As a result, we will not answer to new support incidents starting with May 17th, 2007. Pending support incidents will still be followed in order to be closed. The product forums will remain open and be transformed in user-to-user forums. The general forums will be made read-only and not allow new posts or comments.
For more information about the affected products visit: www.interaktonline.com/Support/
Stephen Biggins
04-11-2006 01:20:00 GMT +2
|
Hi,
Just working my way through the tutorials and I seem to have come across a problem in the Image Gallery > When trying to create a random image for the default page I get this error relating to the SQL in the recordset Dialog box
SELECT *, rand() as random_number FROM image_img ORDER BY random_number DESC LIMIT 1
Syntax error ORDER BY clause
|
|
|
FrederickRM
04-11-2006 07:43:12 GMT +2
|
Something tells me I had this problem too quite some time ago. Oddly enough I was doing this sort of thing today and here is what I am using and it has been working for months with different situations. I have used it for Random Images, Random comments, etc. : SELECT * FROM image_img ORDER BY RAND() Limit 1
Try it and see if it works for you.
|
|
|
Cristian IVASCU[InteraktOnline]
04-11-2006 18:12:52 GMT +2
|
Hi Frederick,
Both SQL queries work on our testing server. The problem may depend on the actual database system you are using - MySQL, Access, etc. so please provide this information.
Regards,
Cristian
|
|
|
Stephen Biggins
04-11-2006 20:41:18 GMT +2
|
Thanks for the help but that doesn't work either?
|
|
|
Stephen Biggins
04-11-2006 20:44:22 GMT +2
|
Hi Cristian,
I'm using an access data base in fact its the one shipped with the tutorial so i don't think thats the problem?
|
|
|
FrederickRM
04-11-2006 21:20:44 GMT +2
|
You should probably post the whole page here so either the support crew or one of the forum dwellers can look it over. I suspect that your query isn't the only problem. Also post your OS, code languange (PHP, ASP, etc.) and Database of choice so we can help you fix it.
|
|
|
Stephen Biggins
04-11-2006 21:38:07 GMT +2
|
As i mentioned earlier i am only working through the image gallery tutorial from the support files, nevertheless i have attached the file . Im using Access and ASP to complete the tutorials? sorry for being a pain, just learning?
|
|
|
Cristian IVASCU[InteraktOnline]
04-12-2006 09:52:41 GMT +2
|
Hi Stephen,
There are two problems with the queries and Microsoft Access:
- Access does not support the LIMIT clause in SQL queries.
- The Rand() function does not exist. Instead you should use rnd().
The query that works is:
SELECT *
FROM image_img
ORDER BY RND();
Hope this helps,
Cristian
|
|
|
Stephen Biggins
04-12-2006 13:48:53 GMT +2
|
Thanks for that at least its got rid of the ORDER BY error i was getting but this statement still does not randomly pick the images i keep getting the same image each time i refresh or reopen the browser?
|
|
|
Cristian IVASCU[InteraktOnline]
04-18-2006 10:21:49 GMT +2
|
Hi Stephen,
And sorry for the late reply, but we have been very busy lately. The problem that you are facing is actually related to ACCESS - although it has rnd() as a random number generating function, it will not return true random results.
To get a random record, you must also use some ASP code. There are two steps to follow in order to get this to work:
- Create a simple recordset on the image_img table. This is done in order to find the last record's ID.
- Switch to code view. After the code defining the query, you must create a new code block that will initialize the random number generator, and create the random number. The code would be similar to the following (assuming the first recordset is named rsNumbers):
<%
Randomize()
random_number = Int(Rnd*RsNumbers_last+1)
%>
- Create a second recordset that retrieves the images. In the recordset user interface click the Advanced button and define a new variable (e.g. random). For the default value enter -1 and for the run-time value use random_number. Then, in the SQL code add a WHERE clause:
SELECT * FROM image_img WHERE id_img <=random
- Click OK to create the recordset, then switch to code view. Make sure that the code block you created is placed before the second recordset code, and after the first one. If it is not, move it in the right position (the random number must be computed before it is used).
- Test the page. The query should return a random image
Note that using Randomize() will not provide fully random results, as it has trends, but is an efficient and fast way of getting pseudo-random data.
Hope this helps,
Cristian
|
|
|
Stephen Biggins
04-19-2006 01:23:01 GMT +2
|
Thanks Christian,
Tried your solution with some partial success, not sure what ive got wrong but i have attached the page if its any help.
|
|
|