Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Drop Down Executes Query On Post? Reply To: Drop Down Executes Query On Post?

#170645
__
Participant

In previous statements I used result as :
$result = mysql_query("SELECT * FROM table");
So I have changed $Link to result :
$result = mysql_connect($Host, $User, $Password);

It’s not the name of the variable that’s the problem, it what it points at. In your first example, $result holds the return value from mysql_query, which is probably a result set.

In your second example, it holds the result from mysql_connect, which is probably a database connection resource.

Notice: Undefined index: message in filter.php on line 5
Notice: Undefined index: usercomments in filter.php on line 10
Why are these flagged?!?!?! They work! They are flagged in other pages as well.

What do you mean by “they work”? If you’re using the html you showed, then they should not “work.” The form you’re using doesn’t have a “usercomments” field, and no GET parameters at all.

Warning: mysql_fetch_row(): supplied resource is not a valid MySQL result resource

That’s because the variable you are passing to it ($result) is either undefined (as in your original code), or is a connection resource (from mysql_connect, as in your modified code).

Yes, that is the logic behind what I want to do.

Alright, let’s outline that in pseudo-code:

<?php

Program Logic:
IF form "rating" was submitted 
AND "rating" is an integer between 1 and 5:
    …connect to the DB
    …query the DB for matching ratings
    IF query is successful:
        …fetch results
        LOOP: for each result,
            …write HTML "star" ratings 
            …write other details

HTML Output:
echo HTML markup
IF there were results from the query
    …insert them into the markup

Right?
Now, we just use those comments as instructions, and add real code that actually does it all.

The gist you posted is marked secret. Would you rather I not disclose any of it?