Home  |  Linux  | Mysql  | PHP  | XML
From:Miller, Terion Date:Wed Jul  1 15:56:04 2009
Subject:Re: Select and compare problems still ...



On 7/1/09 10:29 AM, "Andrew Ballard" <aballard@gmail.com> wrote:

$data = array($ucName, $ucAddress, $inDate, $inType, $notes,
> $critical, $cleanViolations, $noncritical);
>
> $sql = vprintf("INSERT INTO `restaurants` (name, address, inDate,
> inType, notes, critical, cviolations, noncritical) VALUES ('%s', '%s',
> '%s', '%s', '%s', '%s', '%s', '%s')",
> array_map('mysql_real_escape_string', $data));
>
> $result = mysql_query($sql) or die(mysql_error());

Well I had wondered about the escape_string and did it like this, now I have a new problem, it is inserting all the records in the database (making duplicates) I want it to match the records and only insert the ones not there...

Here's my code so far:

$cleanViolations = str_replace('*', '', $cviolations); $ucName = ucwords($name); $ucAddress = ucwords($address); $mysql_name = mysql_escape_string($ucName); $mysql_address = mysql_escape_string($ucAddress); $mysql_inDate = mysql_escape_string($inDate); $mysql_inType = mysql_escape_string($inType); $mysql_notes = mysql_escape_string($notes); $mysql_critical = mysql_escape_string($critical); $mysql_cviolations = mysql_escape_string($cleanViolations); $mysql_noncritical = mysql_escape_string($noncritical); echo "$ucName <br>"; echo "$ucAddress <br>"; echo "$inDate <br>"; echo "$inType <br>"; echo "$notes <br>"; echo "$critical <br>"; //echo "$cviolations <br>"; echo "$cleanViolations <br>"; echo "$noncritical <br><hr>"; //compare entries and insert new inspections to the database //call what is in the database $query = "SELECT * FROM restaurants WHERE name LIKE '$mysql_name' AND address LIKE '$mysql_address' AND inDate LIKE '$mysql_inDate' AND inType LIKE '$mysql_inType'" ; $result = mysql_query($query) or die(mysql_error()); echo $result; $row = mysql_numrows($result); if ($row == 0){ $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, critical, cviolations, noncritical) VALUES (" ; $sql .= " '$ucName', '$ucAddress', '$inDate', '$inType', '$notes', '$critical', '$cleanViolations', '$noncritical')"; $result = mysql_query($sql) or die(mysql_error()); } /**/ };
Navigate in group php.general at sever news.php.net
Previous Next


Your recent visits
HTTPS SSL
Re: We have detected that PHPNET HOSTING SERVICES IS HOSTING A FRAUDULENT WEBSITE that offers a PHISHING SCAM against ALLIANCE LIECESTER.
Re: [PHP] Re: cannot figure out permissions for fopen/fwrite
Re: [PHP] HTTPS SSL
Apache module PHP 5.3 on Windows



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants