Yeah.. I am 100% sure..


Return Values

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.

Use mysql_num_rows() to find out how many rows were returned for a SELECT statement or mysql_affected_rows() to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement.

mysql_query() will also fail and return FALSE if the user does not have permission to access the table(s) referenced by the query.

Source : http://in.php.net/mysql_query
You should get the desired output if you are using a simple select query. Well, what does your function queries return if you use update/delete query ?

This is p*ssing me off.

Ok

I echo both queries once they have been process via mysql_query.

The SELECT STATEMENT returns 1.
The UPDATE STATEMENT returns 1.

So that means something wrong with my query function?

function query($result) {
 return mysql_query($result)  or die("FAILED!!!" . mysql_error());
}

Also if it matters this function is in a seperate file that then is "included" in the php file.

So any ideas?

Thanks nav again, sorry for all this just trying to redo all my websites with functions as I find it abit more professional and oop approach.

PS: Even though the update statement returns a 1 it updates the database correctly, dont ask me how X|.

PPS: And dont forget the code you said should have worked on page 1 did not for me I got the same error for your program that I am for mine now, so could it be a setup issue?

It doesn't matter if you have functions in a separate file and include it in the executing script.

Aaarghhhh ! :@ Do this.. I found the error !

function executequery($query) {
	$x = mysql_query($query) or die(mysql_error());
	return $x;
}

Assign mysql_query to a variable and return it. That works.. Indeed, return mysql_query($query) returns 1. :)

Edit : In my 1st example, I had assigned the value returned by mysql_query to a variable.. You missed it somehow ;)

commented: saved me again, thankyou :) +1

Ok nav once again you solved my problem!

But doing that I dont know why when I copied and pasted your code it did not work :(

Anyways know I can use functions!!!!!!

THANKYOU :) :) :)

Great! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.