Re: Warning: Supplied argument is not a valid MySQL result resource in

From: Date: Tue, 13 May 2003 14:23:29 +0000
Subject: Re: Warning: Supplied argument is not a valid MySQL result resource in
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147438@lists.php.net to get a copy of this message
Can you give us the line number that the error is reporting? Also, just from quickly scanning: I think you should use only one = in the first query. Then, just as a quick pointer: Usually you get these errors because either the query is not valid (generates a sql error when run from the command line or in phpmyadmin), or the result set is empty and the subsequent operations you are trying to do expects some kind of input... But first, let us have the line number... On Tue, 2003-05-13 at 16:09, Awlad Hussain wrote: > does anyone know why i am getting this error? > Warning: Supplied argument is not a valid MySQL result resource in > > the code is given below > > <?php > if($Submit){ > if($catname){ > $link_identifier = mysql_connect("localhost", "user", > "******"); > mysql_select_db("sacc_directory", $link_identifier); > > $sql1 = "SELECT id FROM category WHERE catname=='$catname'"; > $result1 = mysql_query($sql1,$link_identifier); > $num_row = mysql_num_rows($result1); > > if($num_row < 0){ > $sql = "INSERT INTO category (catname) VALUES ('$catname')"; > $result = mysql_query($sql,$link_identifier); > if($result){ > echo "category $catname has been added successfully"; > } > else{ > echo "Problem adding new category"; > } > }else{ > echo "Category $catname already exist"; > } // close if num rows > } > else { > echo "Category name is blank, please go back and type category name"; > } // close if catname > } > ?> > <FORM name="form" method="post" action=""> > <TABLE width="400" border="0" cellspacing="0" > cellpadding="2"> > <TR bgcolor="#8C8CCD"> > <TD colspan="2">&nbsp;</TD> > </TR> > <TR bgcolor="#F4F4FB"> > <TD width="109" class="txtNormal">Category Name:</TD> > <TD width="291"> > <INPUT type="text" name="catname" size="35"> > </TD> > </TR> > <TR bgcolor="#F4F4FB"> > <TD width="109">&nbsp;</TD> > <TD width="291"> > <INPUT type="submit" name="Submit" value="Add New > Category"> > </TD> > </TR> > </TABLE> > </FORM>

« previous php.general (#147438) next »