** the "password.php includes all the username,password,databasename($DBName),and the host.
When I make the selection from the html script,the php files will execute and show me unable to select database error.Can you guys assist me what I have done wrong in the scripts?
that block is your main problem... you are passing the retrieve function variables that do not exist. next, and this is just a recommendation, while you are working, remove teh '@' in front of
thanks for the reply ,I have try out the code as you had written.But no luck, the code still cannot work.Below are the modified code:
retrieve($Category);
function retrieve($Table){
mysql_connect(localhost,$User,$Password);
mysql_select_db($DBName) or die( "Unable to select database");
$query="SELECT * FROM $Table";
$result=mysql_query($query);
I had removed the if..else condition but I still get the unable to select database error even though I had also remove the "@".Is there still anything that I missing?
Sorry, I had solved the previous problem but now exist another problems that is I got this error : Supplied argument is not a valid MySQL result resource in line 35
The problem is not with the num_rows line, as that is fine, but with the line above. Try replacing the two lines above with the code below and see if that makes any difference:
if this removes the error, $Category is probably not being passed correctly. you could also try echoing $Category right into the page, to make sure it's getting through as you expect it. change the method to get, and take a close look at the address line after you submit. of course, change all of these things back after you get it working.
You are using variables as the username and password but haven't set these anyware in the function so your not able to connect to the database.
Another thing is that the way collins told you to do the $catagory thing might not be the best way to do it. If you have sensitave data that is not a very secure plan.
try: