Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old April 11th, 2004, 03:05 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
POST variable in SELECT statement

I created a form to submit a date to a php file, but how do you get the QUERY statement to search for the date submitted by the form?

Reply With Quote
  #2  
Old April 11th, 2004, 01:45 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: POST variable in SELECT statement

$query = select * from mytable where myfield = $_POST[myformfield]";

Reply With Quote
  #3  
Old April 11th, 2004, 04:27 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: POST variable in SELECT statement


The statement above actually received the variable, but the results are blank. I had to enclose the $_POST[variable] in quotes for it to work. I received "syntax error" without the quotes around $_POST. Help me.

Reply With Quote
  #4  
Old April 11th, 2004, 06:24 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: POST variable in SELECT statement

post the code you are currently using that gets tyhe error so I can take a look.

Reply With Quote
  #5  
Old April 12th, 2004, 10:54 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: POST variable in SELECT statement

if (isset ($_POST[submit])) {
}
$query = 'SELECT * FROM Tickets LEFT JOIN Students ON Tickets.`Student Id`=Students.Id WHERE Date="2004-03-25" AND `Comment Id` = "$_POST[code]" ORDER BY `Student Id`';

// Define the query
if ($r = mysql_query ($query)) {

Reply With Quote
  #6  
Old April 13th, 2004, 12:41 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: POST variable in SELECT statement

try the query like this

$query = "SELECT * FROM Tickets LEFT JOIN Students ON Tickets.`Student Id`=Students.Id WHERE Date='2004-03-25' AND `Comment Id` = '$_POST[code]' ORDER BY `Student Id`";

see if that makes any difference. another thing to do would be to echo the query before executing it to see if the query is well formed.


Reply With Quote
  #7  
Old April 13th, 2004, 02:07 PM
dp6116 dp6116 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Memphis, TN US
Posts: 2 dp6116 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: POST variable in SELECT statement


Reply With Quote
  #8  
Old April 13th, 2004, 07:54 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: POST variable in SELECT statement

I don't think arrays get expanded automatically, since it is ambiguous. Try changing $_POST[code] in the query statement to ${_POST['code']}.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > POST variable in SELECT statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT