Re: mysqli insert into table only if not exists
For human readability, use BBCode code tags to retain code formatting.
> only if title field doesn't match one that already exists in the DB.
You mean in the table. If there's a Primary or Unique index on the column, INSERT IGNORE will simplify inserting only if not exists.
$_REQUEST[] includes $_COOKIE[]; does that match your requirement? Usually it's best to be specific, ie reference $_GET[] or $_POST[], whichever your form uses.
> mysqli_query($connect,$query);
Always check the return value of a mysql API func, and always trap for errors, eg ...
$res = mysqli_query($connect,$query) or exit( mysqli_error($connect) );
You've not told us where the $_REQUEST[] elements you're canvassing cam from, and you've not reported a problem or error message.
Subject
Written By
Posted
Re: mysqli insert into table only if not exists
August 13, 2017 11:57AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.