Jump to content

how to stop error if variable not found


iammudassir

Recommended Posts

i have a text field like this <td width="62"> < input name="delivery_no[]" type="text" size="5" value = " <?php if(isset($_POST['select'])) // i set value here for this field { echo $rows[3]['delivery_no']; // this echo $rows is coming from a sql query } ?>"/></td> problem is that if my sql query has this result it echo here BUT when my sql query has no result my page generate an error i just required if my sql query does not have this $rows[0] my field remains blank and i can continue work on other fields. like thisif sql query has $rows[3] echo it other wise do nothing let field blank

Link to comment
Share on other sites

You can use issset() to determine if any variable exist or not. if exist then show up it. if you want to know your query is really returning rows or not, you can mysql_num_rows() or equivalant method of other api(mysqli/pdo)

What's that vertical rectangle in your input field name?
It is not rectangle, it is open and closed square bracets of array notation.
  • Like 2
Link to comment
Share on other sites

You can use issset() to determine if any variable exist or not. if exist then show up it. if you want to know your query is really returning rows or not, you can mysql_num_rows() or equivalant method of other api(mysqli/pdo) It is not rectangle, it is open and closed square bracets of array notation.
can you tell me please how to to set isset to check if variable is present please note i already set if isset $_POST['select']
Link to comment
Share on other sites

isset() also accpets multiplr value. where the all the passed variable must have to set to return a TRUE. it is similar to using isset() with conjugation with && in 'if-else' structure. http://w3schools.invisionzone.com/index.php?showtopic=45820&view=findpost&p=255803 also you can read more about control structure and operators herehttp://php.net/language..operator.conditionalhttp://php.net/language.control_structure

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...