TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-07-2008, 10:21 PM   #1 (permalink)
The Contributor
 
Join Date: Jan 2008
Posts: 87
Thanks: 49
StevenF is on a distinguished road
Default Query With a C# Variable?‏

Hiya


I was wondering if someone could help me out here, please? Big Smile

I'm creating a forum, my threads page has the following query:

SELECT * FROM [threads] WHERE ([forum_name] = ?) ORDER BY [time_created] DESC

The "?" (control value) is the sub-forum which the thread is linked to. Example:

List of Forums:

- Introduce Yourself
- The Lounge
- Another Thread
- Blah Blah Blah

User clicks on The Lounge, loads thread.aspx where Query: SELECT * FROM [threads] WHERE ([forum_name] = ?) ORDER BY [time_created] DESC runs

------------------------------------------------------------------------------------------------------------------------------------------------

Now the page with "The Lounge" threads loads, and I store the querystring into a variable

string forum_name = Page.Request.QueryString["forum_name"];
Page.Response.Write("Now browsing the threads about " + forum_name);

Now the user clicks "New Thread" button, and is presented with a form to fill out. Instead of typing the name of the forum that their thread is to be featured in (i.e. "The Lounge") I would like it to automatically have this filled in, based upon where they came from.

My Insert query then looks like this:

Insert Into threads ([thread_name], [thread_author], [forum_name], [time_created]) Values(?,?,?,?)"

But I'm getting an error saying "No value given for one or more required parameters." So I think the variable isn't passing into the query. Do you know why this might be?

Basically, how do I incorporate the value stored in that variable, into the query?


Thanks a lot!

Kind Regards,
Steven
__________________
My Personal and Photo Blog
StevenF is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ugh, Query in a while statement Aaron Absolute Beginners 2 08-11-2008 06:36 PM
query question Evulness Absolute Beginners 4 04-21-2008 07:46 PM
Query caching xenon Advanced PHP Programming 4 01-29-2008 08:20 PM
Need help with a query webosb MySQL & Databases 5 01-11-2008 10:12 PM
Insert data into two tables with one query CMellor MySQL & Databases 5 12-10-2007 10:46 AM


All times are GMT. The time now is 05:04 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design