if statements

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hgmmy
Forum Commoner
Posts: 25
Joined: Sun Aug 26, 2007 9:16 am

if statements

Post by hgmmy »

Hopefully this is a quick question with a quick answer. Here's an example to go with my question which will be after the example.

Code: Select all

<?php 
include('wp-config.php'); //this were the database connection info is as well as were it connects from.

  $o_theuser = $_POST['theuser'];
  $o_profile = $_POST['profile'];

$update_profile = mysql_query("UPDATE user_allow SET share_info='$o_profile' WHERE ID='{$cur_user_i}' AND reviewers_id='$o_theuser' ");

  if ($o_profile == 'y' || $o_profile == 'n')
 {
  if ($update_profile)
  {
   echo "successful query";
  }
 } else {
 echo "unsuccessful query";
};
?>
Ok so if for an "if condition" you use a variable with a mysql_query in it, will the the condition return true if the query returns successful and false if it returns unsuccessful, and if not what does it take to make a condition that works that way?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

if the query is syntacticly valid, the function will return a resource; otherwise it will return false.

That doesn't speak to whether or not the query did anything however.. try mysql_affected_rows instead.
Post Reply