|
||
|
|
|||||||
| Welcome to the Exploding Garrmondo Weiner Interactive Swiss Army Penis. |
|
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).
|
![]() |
|
|
Thread Tools |
Complete PHP noob needs help
So I got this PHP & mySQL book for dummies and am just blindly typing in some sample scripts. I had a handy SQL database just lying around, so I decide to do something with it, to approximate an Excel table.
No matter what I do, however, I end up with a problem. Error in query: $query. Unknown column '$source' in 'where clause' What I want to do is provide a lot of drop-down lists, and let the user select whatever they want and run the query. There is no text input box here, so I don't think there's a need to sanitize input. My code is as follows: I think the naughty code in question is: $query = 'SELECT `Reporter` , `Partner` , `Value` FROM `database` WHERE `Reporter` LIKE $source AND `Partner` LIKE $destination AND `Year` = $year AND `Flow` = $flow ORDER BY `Reporter`,`Partner`'; BUT I already did define the variables earlier: $source = $S_POST['source']; $destination = $S_POST['destination']; $year = $S_POST['year']; $flow = $S_POST['flow']; So... what am I doing wrong ![]() How ya doing, buddy? |
Enclosing the variables in apostrophes work! Thanks Secret.
Now I'm encountering another problem. I've now split up the code into two parts. The first part contains just a set of forms with a submit button. The second part contains the PHP code. It seems PHP is not picking up on the options posted to it, and so all the variables $source $destination $year and $flow are NULL. I have tested the mysql query by manually defining each variable, and it works. So the error now is that the option values are not being picked up. My forms code are: Code:
<form method="post" action="Result.php" target="bottomFrame">
<table width="100%" border="1">
<tr>
<td>Source Country</td>
<td>Destination</td>
<td>Trade Flow</td>
<td>Year</td>
</tr>
<tr>
<td><select name="source" id="source">
<option value='%'>List all countries</option>
...
<input type="submit" name="submit" id="submit" value="Display Data"></center>
</p>
</form>
Implementation here Thoughts? How ya doing, buddy? |
Well I'll be. I'm blind. That did the trick ^____^ Thanks Blah!
I didn't know people can automagically insert post elements where none is editable. But since I'm now getting a working result, I can attempt scrubbing at my leisure. (Though, since the database user has SELECT privileges only, there's probably not too much damage they can do...) This thing is sticky, and I don't like it. I don't appreciate it. |
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Questions from a complete noob about ripping ... | Dark Rubes | Behind the Music | 7 | Jan 8, 2007 03:25 AM |