Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

MySQL and Irish Surnames

  • 18-04-2005 5:48pm
    #1
    Registered Users, Registered Users 2 Posts: 884 ✭✭✭


    Lads, I am trying to INSERT data into my database but i am having trouble with Irish surnames i.e. O'Brien, O'Callaghan, O'Kelly ...... it doesnt like the apostrophe !!

    Is there an thing i can do about this, i was hoping to leave them as varchar .... has anyone come across this before ??

    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresp
    onds to your MySQL server version for the right syntax to use near ''Brien,Cork,
    Irish,000005),
    (00000007,George,O'Callaghan,Cork,I
    Query OK, 0 rows affected (0.00 sec)
    


«1

Comments

  • Closed Accounts Posts: 5,019 ✭✭✭ct5amr2ig1nfhp


    Its not difficult to fix but I think it depends what language you are developing in?

    A quick google for "<language> mysql apostrophes" should help you.

    ambrose :cool:


  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    Use an escape character \ to allow you to put in the apostrophe.


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    MySQL is the language !!

    I replaced all the ' with \' and tried it .... got this
    ERROR:
    Unknown command '\''.
    ERROR:
    Unknown command '\''.
    ERROR:
    Unknown command '\''.
    ERROR:
    Unknown command '\''.
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresp
    onds to your MySQL server version for the right syntax to use near '\'Brien,Cork
    ,Irish,000005),
    (00000007,George,O\'Callaghan,Cork
    Query OK, 0 rows affected (0.00 sec)
    


  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    Are you inserting this : George,O\'Callaghan,Cork
    or this : "George","O\'Callaghan","Cork" ?


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    0utshined wrote:
    Are you inserting this : George,O\'Callaghan,Cork
    or this : "George","O\'Callaghan","Cork" ?

    The first one !?!?!??

    Is that right ??


  • Advertisement
  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    I don't think so, you need to quote a string IIRC (haven't done SQL in a long time).
    You may need to use ' to quote rather than "

    ***Edit:

    Two links one two


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    0utshined wrote:
    You may need to use ' to quote rather than "

    I wasn't using either to be honest barr the ' for the apostrophes !!

    This is a sample of the flat file ...
    (00000005,Neal,Horgan,Cork,Irish,000005),
    (00000006,Colin,O\'Brien,Cork,Irish,000005),
    (00000007,George,O\'Callaghan,Cork,Irish,000005),
    (00000008,Joe,Gamble,Cork,Irish,000005),
    


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    0utshined wrote:
    Are you inserting this : George,O\'Callaghan,Cork
    or this : "George","O\'Callaghan","Cork" ?

    Am i right in saying that i need to use something like this ... 'the_value'

    Is the just for O\'Callaghan etc. or is it for everything ?

    I didn't think i needed to use them for varchar's ??!!?


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    Try:

    $variablename = mysql_real_escape_string($variablename);

    That should make it so that the special characters don't mess about with your MySQL statement.

    (www.php.net/mysql_real_escape_string)


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    I got this when i put all the values into ""
    ERROR:
    Unknown command '\&#198;'.
    ERROR:
    Unknown command '\&#198;'.
    ERROR:
    Unknown command '\&#198;'.
    ERROR:
    Unknown command '\&#198;'.
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresp
    onds to your MySQL server version for the right syntax to use near '\&#198;Brien&#246;,&#246;Co
    rk&#246;,&#246;Irish&#246;,000005),
    (00000007,&#246;George&#246;,&#246;O\&#198;Callag
    Query OK, 0 rows affected (0.00 sec)
    

    and i got this when i replaced all the " with '
    ERROR:
    Unknown command '\&#198;'.
    ERROR:
    Unknown command '\&#198;'.
    ERROR:
    Unknown command '\&#198;'.
    ERROR:
    Unknown command '\&#198;'.
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresp
    onds to your MySQL server version for the right syntax to use near '\&#198;Brien&#198;,&#198;Co
    rk&#198;,&#198;Irish&#198;,000005),
    (00000007,&#198;George&#198;,&#198;O\&#198;Callag
    Query OK, 0 rows affected (0.00 sec)
    



    ciaranfo wrote:
    $variablename = mysql_real_escape_string($variablename);

    Are you saying put that into MySQL command line (I am not using Php yet .... i am still working on the data entry in my database)


  • Advertisement
  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    Sorry, I just assumed you were using PHP. Rather stupid of me..


    Just use the escapes then to put before any odd characters as suggested.

    So if you have o'shea then replace it with o\'shea. Only use it where needed.


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    ciaranfo wrote:
    Sorry, I just assumed you were using PHP. Rather stupid of me..


    Just use the escapes then to put before any odd characters as suggested.

    So if you have o'shea then replace it with o\'shea. Only use it where needed.


    I have tried that and it doesn't work ...... I tried three things tbh and none of them work ..... here there are:


    1. (00000006,Colin,O\’Brien,Cork,Irish,000005),

    2. (00000006,"Colin","O\’Brien","Cork","Irish",000005),

    3. (00000006,'Colin','O\’Brien','Cork','Irish',000005),


    And still no joy !!

    Any ideas ??


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    Shouldn't that be:

    (00000006,'Colin,O\’Brien','Cork','Irish',000005),

    ?


    NVM: you edited as I was posting :)


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    ciaranfo wrote:
    Shouldn't that be:

    (00000006,'Colin,O\’Brien','Cork','Irish',000005),


    No ... PLayerNo, FirstName, Surname, Town, Nationality, ClubNo

    I need to keep the First and Surname seperate so surname is the problem value !!


  • Registered Users, Registered Users 2 Posts: 5,741 ✭✭✭jd


    Cork Skate wrote:
    No ... PLayerNo, FirstName, Surname, Town, Nationality, ClubNo

    I need to keep the First and Surname seperate so surname is the problem value !!
    PLayerNo and ClubNo may have to be in quotes too-


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    Can you give us the various datatypes ?


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    ciaranfo wrote:
    Can you give us the various datatypes ?

    What do you mean .... a few lines of data that is being used ?? sure
    (00000005,Neal,Horgan,Cork,Irish,000005),
    (00000006,Colin,O\'Brien,Cork,Irish,000005),
    (00000007,George,O\'Callaghan,Cork,Irish,000005),
    (00000008,Joe,Gamble,Cork,Irish,000005),
    

    but it now has ' around the text.

    I'll try it now around the Nos aswell


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    No, what I mean is text, int, etc


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Cork Skate wrote:
    I'll try it now around the Nos aswell

    I tried it around all the int and still the same

    ciaranfo wrote:
    No, what I mean is text, int, etc

    The datatypes ... you should have said !! :p

    Here is part of the CREATE statement
    MemberNo		integer		not null,
    FIrstName		Varchar(32)	not null default '',
    Surname			Varchar(32)	not null default '',
    PlaceOfBirth		Varchar(32)	null default '',
    Nationality		Varchar(32)	null default '',
    ClubNo			integer		null default '',
    


  • Registered Users, Registered Users 2 Posts: 5,741 ✭✭✭jd


    can you post up the exact sql@?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 32,136 ✭✭✭✭is_that_so


    MySQL uses ANSI SQL and the escape used is a second apostrope.

    so O'Callaghan becomes 'o''Callaghan'

    your insert therefore would be

    insert into my table ( Name) values ('o''Callaghan');


  • Closed Accounts Posts: 5,019 ✭✭✭ct5amr2ig1nfhp


    My apologies long day yesterday.

    Have you tried double quotes, as is_that_so suggested?

    O’Brien -> O’’Brien

    ambrose :cool:


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    My apologies long day yesterday.

    Have you tried double quotes, as is_that_so suggested?

    O’Brien -> O’’Brien

    ambrose :cool:

    Tried the O"Brien option ..... got this !!

    ERROR 1054: Unknown column 'Michael' in 'field list'
    Query OK, 0 rows affected (0.00 sec)


  • Closed Accounts Posts: 14,483 ✭✭✭✭daveirl


    This post has been deleted.


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Lads ... here it is ....

    This is the CREATE table .........

    CREATE TABLE Member(
    MemberNo integer not null,
    FIrstName Varchar(32) not null default '',
    Surname Varchar(32) not null default '',
    PlaceOfBirth Varchar(32) null default '',
    Nationality Varchar(32) null default '',
    ClubNo integer null default '',
    INDEX ClubNo_Index (ClubNo),
    CONSTRAINT MemberNo_Required PRIMARY KEY(MemberNo),
    )TYPE=InnoDB;
    COMMIT;

    With this added later on ......

    ALTER TABLE member ADD CONSTRAINT PresentClub_check FOREIGN KEY (ClubNo) REFERENCES Club(ClubNo);
    COMMIT;

    And this is the data i am trying to add to this table ...

    INSERT INTO member VALUES
    (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005),
    (00000002,’Danny’,’Murphy’,’London’,’English’,000005),
    (00000003,’Alan’,’Bennett’,’Cork’,’Irish’,000005),
    (00000004,’Dan’,’Murray’,’Cambridge’,’Irish’,000005),
    (00000005,’Neal’,’Horgan’,’Cork’,’Irish’,000005),
    (00000006,’Colin’,’O\’Brien’,’Cork’,’Irish’,000005),
    (00000007,’George’,’O\’Callaghan’,’Cork’,’Irish’,000005),
    (00000008,’Joe’,’Gamble’,’Cork’,’Irish’,000005),
    (00000009,’Liam’,’Kearney’,’Cork’,’Irish’,000005),
    (00000010,’Kevin’,’Doyle’,’Wexford’,’Irish’,000005),
    (00000011,’John’,’O\’Flynn’,’Cork’,’Irish’,000005),
    (00000012,’Steve’,’Williams’,’Aberystwyth’,’Welsh’,000018),
    (00000013,’Owen’,’Heary’,’Dublin’,’Irish’,000018),
    (00000014,’David’,’Crawley’,’Dundalk’,’Irish’,000018),
    (00000015,’Jamie’,’Harris’,’Swansea’,’Welsh’,000018),
    (00000016,’Colin’,’Hawkins’,’Galway’,’Irish’,000018),
    (00000017,’Wesley’,’Hoolahan’,’Dublin’,’Irish’,000018),
    (00000018,’Ollie’,’Cahill’,’Clonmel’,’Irish’,000018),
    (00000019,’Stuart’,’Byrne’,’Dublin’,’Irish’,000018),
    (00000020,’Alan’,’Crawley’,’Sligo’,’Irish’,000018),
    (00000021,’Glen’,’Fitzpatrick’,’Dublin’,’Irish’,000018),
    (00000022,’Jason’,’Byrne’,’Dublin’,’Irish’,000018),
    (00000023,’Patrick’,’Holden’,’Kilkenny’,’Irish’,000022),
    (00000024,’Neil’,’Andrews’,’Kilkenny’,’Irish’,000022),
    (00000025,’John’,’Frost’,’Limerick’,’Irish’,000022),
    (00000026,’Kevin’,’Doherty’,’Dublin’,’Irish’,000022),
    (00000027,’Pat’,’Purcell’,’Dublin’,’Irish’,000022),
    (00000028,’Stephen’,’Yelverton’,’Cork’,’Irish’,000022),
    (00000029,’Alan’,’Reynolds’,’Waterford’,’Irish’,000022),
    (00000030,’Sean’,’Finn’,’Dublin’,’Irish’,000022),
    (00000031,’Kevin’,’Waters’,’Wexford’,’Irish’,000022),
    (00000032,’Daryl’,’Murphy’,’Waterford’,’Irish’,000022),
    (00000033,’Willie’,’Bruton’,’Cork’,’Irish’,000022),
    (00000034,’David’,’Forde’,’Galway’,’Irish’,000022),
    (00000035,’Dan’,’Connor’,’Dublin’,’Irish’,000007),
    (00000036,’Damien’,’Lynch’,’Dublin’,’Irish’,000007),
    (00000037,’Simon’,’Webb’,’London’,’English’,000007),
    (00000038,’Steven’,’Grey’,’Dublin’,’Irish’,000007),
    (00000039,’Stuart’,’Malcolm’,’Edinburgh’,’Scottish’,000007),
    (00000040,’Graham’,’Gartland’,’Dublin’,’Irish’,000007),
    (00000041,’Shane’,’Robinson’,’Waterford’,’Irish’,000007),
    (00000042,’Sami’,’Ristilla’,’Valkeakoski’,’Finnish’,000007),
    (00000043,’Declan’,’O\’Brien’,’Dublin’,’Irish’,000007),
    (00000044,’Mark’,’Rooney’,’Dublin’,’Irish’,000007),
    (00000045,’Alan’,’Reilly’,’Dublin’,’Irish’,000007);
    COMMIT;


    Any ideas ??


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    daveirl wrote:
    This post has been deleted.

    I am fairly close to that option now !! :D

    But what do the French do for this though ??

    J'espérerais qu'il travaillerait à cause de toutes les apostrophes qu'ils utilisent !
    I would hope it would work because of all the apostrophes they use !


  • Registered Users, Registered Users 2 Posts: 5,741 ✭✭✭jd


    Cork Skate wrote:
    Lads ... here it is ....



    INSERT INTO member VALUES
    (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005),
    (00000002,’Danny’,’Murphy’,’London’,’English’,000005),
    (00000045,’Alan’,’Reilly’,’Dublin’,’Irish’,000007);
    COMMIT;


    Any ideas ??

    INSERT INTO member VALUES (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005);
    INSERT INTO member VALUES (00000002,’Danny’,’Murphy’,’London’,’English’,000005);


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    jd wrote:
    INSERT INTO member VALUES (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005);
    INSERT INTO member VALUES (00000002,’Danny’,’Murphy’,’London’,’English’,000005);

    OK .... i geddit now !!


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    A double apostraphe is definately the answer to your original question. Make sure you use 2 apostraphes as opposed to 1 double quote.
    Use '' Not "
    


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Lads, i am getting this about 45 time !!

    ERROR 1054: Unknown column 'Michael' in 'field list'

    It has a problem with the Firstname column !!


  • Registered Users, Registered Users 2 Posts: 5,741 ✭✭✭jd


    Cork Skate wrote:
    Lads, i am getting this about 45 time !!

    ERROR 1054: Unknown column 'Michael' in 'field list'

    It has a problem with the Firstname column !!

    INSERT INTO member ( MemberNo, FIrstName , Surname, PlaceOfBirth, Nationality , ClubNo )VALUES (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005);


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    And do it like this .....

    INSERT INTO member ( MemberNo, FIrstName , Surname, PlaceOfBirth, Nationality , ClubNo )VALUES (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005);
    (00000002,’Danny’,’Murphy’,’London’,’English’,000005);


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    Cork Skate wrote:
    And do it like this .....
    Nope. One set of values for each INSERT statement.


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Alright ...... i was posting and didn't read fully

    INSERT INTO member ( MemberNo, FIrstName , Surname, PlaceOfBirth, Nationality , ClubNo ) VALUES
    (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005);
    INSERT INTO member ( MemberNo, FIrstName , Surname, PlaceOfBirth, Nationality , ClubNo ) VALUES
    (00000002,’Danny’,’Murphy’,’London’,’English’,000005);


    and so on !!


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    Redundant


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Cork Skate wrote:
    INSERT INTO member ( MemberNo, FIrstName , Surname, PlaceOfBirth, Nationality , ClubNo ) VALUES
    (00000001,’Michael’,’Devine’,’Cork’,’Irish’,000005);
    INSERT INTO member ( MemberNo, FIrstName , Surname, PlaceOfBirth, Nationality , ClubNo ) VALUES
    (00000002,’Danny’,’Murphy’,’London’,’English’,000005);

    Lads .... i am still getting this

    ERROR 1054: Unknown column 'Michael' in 'field list'
    ERROR 1054: Unknown column 'Danny' in 'field list'

    on for each row !!


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Check this one out !!!

    ’ is not the same as '

    I was using Microsoft Word to 'replace' and then paste back into notepad

    And it didn't say anything about the \' so it must be good (if not i'll try \ ' + ')



    I still have a problem ........

    ERROR 1216: Cannot add or update a child row: a foreign key constraint fails


    How do i update a column if i dont have the other on updated yet ??


  • Closed Accounts Posts: 4,842 ✭✭✭steveland?


    I know you're not at this point yet but it might be helpful for you to become accustomed to using addslashes and stripslashes when you begin using php with your database (as I assume you will be doing)

    This way when someone enters something into your database (again this is just assuming you're not going to be inputting all the details yourself) it handles if someone uses a ' or is quoting something using ""'s

    http://ie2.php.net/addslashes

    Again it's off-topic to an extent but it's handy to know when handling names


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    Have you tried Member instead of member? You have it capitalized in your Create. Can't remember offhand how case sensitive MySQL is but you should always keep it the same anyway.


  • Closed Accounts Posts: 36 Caixa


    Your code worked perfectly on my mysql install. This is what phpmyadmin suggests to enter it, you may as well give it a go:

    INSERT INTO `member` VALUES (1, 'Michael', 'Devine', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (2, 'Danny', 'Murphy', 'London', 'English', 5);
    INSERT INTO `member` VALUES (3, 'Alan', 'Bennett', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (4, 'Dan', 'Murray', 'Cambridge', 'Irish', 5);
    INSERT INTO `member` VALUES (5, 'Neal', 'Horgan', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (6, 'Colin', 'O\'Brien', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (7, 'George', 'O\'Callaghan', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (8, 'Joe', 'Gamble', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (9, 'Liam', 'Kearney', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (10, 'Kevin', 'Doyle', 'Wexford', 'Irish', 5);
    INSERT INTO `member` VALUES (11, 'John', 'O\'Flynn', 'Cork', 'Irish', 5);
    INSERT INTO `member` VALUES (12, 'Steve', 'Williams', 'Aberystwyth', 'Welsh', 18);
    INSERT INTO `member` VALUES (13, 'Owen', 'Heary', 'Dublin', 'Irish', 18);
    INSERT INTO `member` VALUES (14, 'David', 'Crawley', 'Dundalk', 'Irish', 18);
    INSERT INTO `member` VALUES (15, 'Jamie', 'Harris', 'Swansea', 'Welsh', 18);
    INSERT INTO `member` VALUES (16, 'Colin', 'Hawkins', 'Galway', 'Irish', 18);
    INSERT INTO `member` VALUES (17, 'Wesley', 'Hoolahan', 'Dublin', 'Irish', 18);
    INSERT INTO `member` VALUES (18, 'Ollie', 'Cahill', 'Clonmel', 'Irish', 18);
    INSERT INTO `member` VALUES (19, 'Stuart', 'Byrne', 'Dublin', 'Irish', 18);
    INSERT INTO `member` VALUES (20, 'Alan', 'Crawley', 'Sligo', 'Irish', 18);
    INSERT INTO `member` VALUES (21, 'Glen', 'Fitzpatrick', 'Dublin', 'Irish', 18);
    INSERT INTO `member` VALUES (22, 'Jason', 'Byrne', 'Dublin', 'Irish', 18);
    INSERT INTO `member` VALUES (23, 'Patrick', 'Holden', 'Kilkenny', 'Irish', 22);
    INSERT INTO `member` VALUES (24, 'Neil', 'Andrews', 'Kilkenny', 'Irish', 22);
    INSERT INTO `member` VALUES (25, 'John', 'Frost', 'Limerick', 'Irish', 22);
    INSERT INTO `member` VALUES (26, 'Kevin', 'Doherty', 'Dublin', 'Irish', 22);
    INSERT INTO `member` VALUES (27, 'Pat', 'Purcell', 'Dublin', 'Irish', 22);
    INSERT INTO `member` VALUES (28, 'Stephen', 'Yelverton', 'Cork', 'Irish', 22);
    INSERT INTO `member` VALUES (29, 'Alan', 'Reynolds', 'Waterford', 'Irish', 22);
    INSERT INTO `member` VALUES (30, 'Sean', 'Finn', 'Dublin', 'Irish', 22);
    INSERT INTO `member` VALUES (31, 'Kevin', 'Waters', 'Wexford', 'Irish', 22);
    INSERT INTO `member` VALUES (32, 'Daryl', 'Murphy', 'Waterford', 'Irish', 22);
    INSERT INTO `member` VALUES (33, 'Willie', 'Bruton', 'Cork', 'Irish', 22);
    INSERT INTO `member` VALUES (34, 'David', 'Forde', 'Galway', 'Irish', 22);
    INSERT INTO `member` VALUES (35, 'Dan', 'Connor', 'Dublin', 'Irish', 7);
    INSERT INTO `member` VALUES (36, 'Damien', 'Lynch', 'Dublin', 'Irish', 7);
    INSERT INTO `member` VALUES (37, 'Simon', 'Webb', 'London', 'English', 7);
    INSERT INTO `member` VALUES (38, 'Steven', 'Grey', 'Dublin', 'Irish', 7);
    INSERT INTO `member` VALUES (39, 'Stuart', 'Malcolm', 'Edinburgh', 'Scottish', 7);
    INSERT INTO `member` VALUES (40, 'Graham', 'Gartland', 'Dublin', 'Irish', 7);
    INSERT INTO `member` VALUES (41, 'Shane', 'Robinson', 'Waterford', 'Irish', 7);
    INSERT INTO `member` VALUES (42, 'Sami', 'Ristilla', 'Valkeakoski', 'Finnish', 7);
    INSERT INTO `member` VALUES (43, 'Declan', 'O\'Brien', 'Dublin', 'Irish', 7);
    INSERT INTO `member` VALUES (44, 'Mark', 'Rooney', 'Dublin', 'Irish', 7);
    INSERT INTO `member` VALUES (45, 'Alan', 'Reilly', 'Dublin', 'Irish', 7);


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,741 ✭✭✭jd


    Cork Skate wrote:
    Check this one out !!!

    ’ is not the same as '

    I was using Microsoft Word to 'replace' and then paste back into notepad

    And it didn't say anything about the \' so it must be good (if not i'll try \ ' + ')



    I still have a problem ........

    ERROR 1216: Cannot add or update a child row: a foreign key constraint fails


    How do i update a column if i dont have the other on updated yet ??

    ok - you mean you were quoting with ` instead of ' ?

    do the inserts fail on the commit? can you mot satisy the constarint before the commit?


  • Closed Accounts Posts: 4,842 ✭✭✭steveland?


    Cork Skate wrote:
    I was using Microsoft Word to 'replace' and then paste back into notepad


    You know notepad has a replace function (Ctrl+h), this might be more helpful because it uses plaintext whereas Word tends to add those dodgy line break symbols which can be a pain.


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    steveland? wrote:
    I know you're not at this point yet but it might be helpful for you to become accustomed to using addslashes and stripslashes when you begin using php with your database (as I assume you will be doing)

    This way when someone enters something into your database (again this is just assuming you're not going to be inputting all the details yourself) it handles if someone uses a ' or is quoting something using ""'s

    http://ie2.php.net/addslashes

    Again it's off-topic to an extent but it's handy to know when handling names


    Steve ... thanks for that ..... yup ... i'll be using Php

    That will ( echo addslashes($str); ) be on the webpage i take it when taking in the user input ??


  • Closed Accounts Posts: 4,842 ✭✭✭steveland?


    When someone is adding their details you'll be using a form.

    So when they submit it you want to declare variables for each element of the form,

    ie
    $name = $_POST['name']
    
    This means you're going to be taking the form field named name and assigning it to $name

    when you go to insert that into your table your code should look something like this
    $name = $_POST['name'];
    $name = addslashes($name);
    $sql = "INSERT INTO table VALUES ("$name");
    

    and then when you pull info from the database you'll want to use something like
    $sql = "SELECT * from table";
    
    --- some other code which allows you to assign variables to the fields you pull which i won't go into here ---
    
    $name = stripslashes($name);
    echo "$name";
    

    This means if you input a name like John O'Reilly it'll put it into the db as John O\'Reilly and when it takes it out it'll convert it back to John O'Reilly


  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    Some others suggested the \' to solve your problem. I don't want to call them liars but to my knowledge this won't work. Use the '' like I said above.

    Muckwarrior, I believe this was me but I did warn that I hadn't done SQL in a while. That's the escape character for C\C++ and this link from the MySQL homepages suggests it should work.


    OP,

    Ditch Notepad and Word and use something like Textpad.


  • Closed Accounts Posts: 4,842 ✭✭✭steveland?


    0utshined wrote:
    Ditch Notepad and Word and use something like Textpad.
    I second this motion, or Google for Pspad (tabbed editor :))


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    Caixa wrote:
    Your code worked perfectly on my mysql install. This is what phpmyadmin suggests to enter it, you may as well give it a go:


    Caixa, tried that and still the same !?!

    jd wrote:
    do the inserts fail on the commit? can you mot satisy the constarint before the commit?

    Yeah .... 45 beeps all in one go :)

    I cant really .... i mean .... i'll get caught some where because nearly every tables will have a/a few foreign keys ..... i'll always get caught .... unless i take out the foreign constraint now .... update and Alter it later ...... is that wise though ??


  • Registered Users, Registered Users 2 Posts: 4,100 ✭✭✭muckwarrior


    0utshined wrote:
    Muckwarrior, I believe this was me but I did warn that I hadn't done SQL in a while. That's the escape character for C\C++ and this link from the MySQL homepages suggests it should work.
    Sorry. Was actually just after editing that post. I never seen it done that way, just wanted to point out that I knew my way worked for sure


  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    No bother, like I say I haven't used SQL in a while so all I'm doing is quoting a link, if you have first hand experience I'm sure that's more beneficial to the OP.

    OP,
    Are you sure one of the earlier inserts didn't work? Are you clearing down your database before adding the data in again?


  • Registered Users, Registered Users 2 Posts: 884 ✭✭✭Cork Skate


    0utshined wrote:
    Are you sure one of the earlier inserts didn't work? Are you clearing down your database before adding the data in again?

    Spot the newbie here !! :) .... how do i do that ??

    Would it be

    DELETE FROM member VALUES ???


  • Advertisement
Advertisement