General queries

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Guys,

I have some wierd MySQL queries. Although I am using ADODB (an
abstraction layer) - the queries will probably be quite general.

1) When I post data in a url (i.e. post.php?id=120) and I use this
code: $var = secure_field($id); it will work (on the
"recieve_page.php"). However if I use $secure_field($_POST['$id']) or
any POST/GET/REQUEST type option, it won't work. Its fine, because
secure_field does what I need, however I'm just not sure why its not
picking it up. (If I probe $var - the result is blank)

2) I have a table, where I want a delete button at the end of each row
(as opposed to when only one record is displayed on the screen). I also
don't want to have to post to an external delete.php file. Is there a
way to do this?

For example:
 print "<tr>
<TD><a href='another_page.php?id=$id'>Edit</a></TD>
<TD><a href='this_page.php?id=$id2'>Delete</a></TD>

Where $id = $rs->fields[0]

Even with hardcoded MySQL I have never been able to resolve this delete
per row problem. Any help would be great.


Re: General queries

Quoted text here. Click to load it

Hmm.  You mention ADODB, but the coding questions you are asking involve
PHP.  Also, I don't see any MySQL question in your posting.  Perhaps you
would get a more specific reply from a PHP newsgroup.

Quoted text here. Click to load it

What is secure_field()?  Is this a function of yours?

The expression $id is a variable.  Passing the variable to the
secure_field() function substitutes the value of $id, not the string '$id'.
What is the value of $id?  Presumably it contains the name of the request
parameter you're reading.

Quoted text here. Click to load it

In PHP, putting '$id' in quotes prevents the variable from being expanded.
So the expression is trying to find an entry in the _POST parameter array
whose name is literally '$id', not the value of the $id variable as in the
other example above.

Quoted text here. Click to load it
. . .
Quoted text here. Click to load it

You could make the href='this_page.php?id=$id2;action=delete' and then look
for the 'action' parameter in your php script.  If the value is delete, then
delete the specified entry.  If the value of the action parameter is not
delete, then it defaults to edit.

Bill K.

Site Timeline