Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Duplicate Entry Script.
Old 05-02-2008, 09:24 AM Duplicate Entry Script.
Novice Talker

Posts: 5
Trades: 0
Just trying to make a a simple IF else script. IF <whatever table> ==0 Print "Duplicate Entry on $tablename" Else $insertSql. Any direction/help would be great

Thanks:
Here is the code im using for insert.

PHP Code:

<?php
include('general/header.inc');
require_once(
'general/general.php');

if (!(isset(
$_POST['SubmitForm_x'])))
?>

<<<<HTML Forms CODE is here >>>>>

<?php } else {

$insertSql "INSERT INTO millidgeville (
sticker
,serial
,computer_name
,item
,brand
,model
,cdrom
,cpu_type
,hdd
,cpu_speed
,memory_type
,memory_install
,school
,room
,computer_use
,computer_use_other
,licence_software
,licence_software_other
,comments


) VALUES ( "
." '".addslashes($_POST['sticker'])."'"
.", '".addslashes($_POST['serial'])."'"
.", '".addslashes($_POST['computer_name'])."'"
.", '".addslashes($_POST['item'])."'"
.", '".addslashes($_POST['brand'])."'"
.", '".addslashes($_POST['model'])."'"
.", '".addslashes($_POST['cdrom'])."'"
.", '".addslashes($_POST['cpu_type'])."'"
.", '".addslashes($_POST['hdd'])."'"
.", '".addslashes($_POST['cpu_speed'])."'"
.", '".addslashes($_POST['memory_type'])."'"
.", '".addslashes($_POST['memory_install'])."'"
.", '".addslashes($_POST['school'])."'"
.", '".addslashes($_POST['room'])."'"
.", '".addslashes($_POST['computer_use'])."'"
.", '".addslashes($_POST['computer_use_other'])."'"
.", '".addslashes($_POST['licence_software'])."'"
.", '".addslashes($_POST['licence_software_other'])."'"
.", '".addslashes($_POST['comments'])."'"

.")";

$MyDb->f_ExecuteSql($insertSql);

?>
vipernet is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-02-2008, 09:57 AM Re: Duplicate Entry Script.
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
If you are using mysql, you can rely on the ON DUPLICATE KEY syntax.
Basically, if the primary key is already existing, you can provide an update statement after the insert, and it's this update that will be ran

http://dev.mysql.com/doc/refman/5.0/...duplicate.html
Code:
INSERT INTO table (a,b,c) VALUES (1,2,3)
  ON DUPLICATE KEY UPDATE c=c+1;
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Duplicate Entry Script.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09599 seconds with 12 queries