Page 1 of 1

excecute if $mysqli->query successfull

Posted: Sat Jan 01, 2011 11:52 am
by someguyhere
I'm trying to execute something only of the data is successfully inserted into the database, but I'm clearly doing something wrong. I've done as bit of digging around the forum, and it looks like the solutions to similar issues are for older versions of php...I could be wrong through, I'm just at the beginning of learning php. Anyway, I've tried to piece together the code based on what I've found on the forum, but it doesn't seem to be working - in this case, it executes whether the data is successfully inserted into the database or not.

Code: Select all

		$mysqli->query("INSERT INTO ag_pages (page_date, page_type, page_url, page_keyword, page_title, page_content) VALUES ('$page_date', '$page_type', '$new_page_url', '$new_page_keyword', '$new_page_title', '$new_page_content')");

		if($mysqli){
			stuff to excecute here
}
If I change it to

Code: Select all

		if($mysqli->query){
Then it doesn't execute at all. I'm at a loss as to what to do here. Any advice?

Re: excecute if $mysqli->query successfull

Posted: Sat Jan 01, 2011 12:04 pm
by Darhazer

Code: Select all

$result = $mysqli->query("INSERT INTO ag_pages (page_date, page_type, page_url, page_keyword, page_title, page_content) VALUES ('$page_date', '$page_type', '$new_page_url', '$new_page_keyword', '$new_page_title', '$new_page_content')");

                if($result){
                        stuff to excecute here

Re: excecute if $mysqli->query successfull

Posted: Sat Jan 01, 2011 12:54 pm
by someguyhere
Thanks! Worked perfectly!