0

I am trying to create a table using mysql and php I do not understand why this fails maybe someone can help me.

<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', '');

$createcontextuallinksettingstable = $dbh->prepare("
CREATE TABLE IF NOT EXISTS ContextualLinkSettings
(
Window_Onload TEXT,
Use_Monetizer TEXT,
Apple_Link_Check TEXT,
Amazon_Link_Check TEXT,
Clickbank_Link_Check TEXT,
Commission_Junction_Link_Check TEXT,
Ebay_Link_Check TEXT,
Linkshare_Link_Check TEXT,
Ad_Timer TEXT,
Use_Apple TEXT,
Use_Amazon TEXT,
Use_Clickbank TEXT,
Use_Commission_Junction TEXT,
Use_Ebay TEXT,
Use_Linkshare TEXT,
Apple_Affiliate_Token TEXT,
Apple_Campaign_Value TEXT,
Apple_Country TEXT,
Amazon_Associate_ID TEXT,
Amazon_AWS_Access_Key_ID TEXT,
Amazon_AWS_Secret_Key TEXT,
Amazon_Country TEXT,
Clickbank_Affiliate_ID TEXT,
Clickbank_Customisation TEXT,
Clickbank_Affiliate_Tracking_ID TEXT,
Microsoft_Client_ID TEXT,
Microsoft_Client_Secret TEXT,
Commission_Junction_Site_ID TEXT,
Commission_Junction_API_Key TEXT,
Commission_Junction_Country TEXT,
Commission_Junction_Currency_Type TEXT,
Commission_Junction_Low_Price TEXT,
Commission_Junction_High_Price TEXT,
Ebay_App_Id TEXT,
Ebay_Country TEXT,
Ebay_Sort_Order TEXT,
Ebay_Category_ID TEXT,
Linkshare_Token TEXT,
Linkshare_Advertiser_MID TEXT,
Main_Path TEXT,
Use_Monetizer TEXT,
Popup_Font_Color TEXT,
Popup_Link_Color TEXT,
Popup_Link_Hover_Color TEXT,
Popup_Link_Font_Color TEXT,
Popup_Link_Link_Color TEXT,
Popup_Link_Link_Hover_Color TEXT,
Apple_Explicit TEXT,
Apple_Link_Check TEXT,
Apple_Auto_Generated TEXT,
Amazon_Auto_Generated TEXT,
Amazon_Link_Check TEXT,
Commission_Junction_Advertiser_Relationship TEXT,
Commision_Junction_Cache_Duration TEXT,
Commission_Junction_Auto_Generated TEXT,
Commission_Junction_Link_Check TEXT,
Linkshare_Auto_Generated TEXT,
Linkshare_Link_Check TEXT,
Clickbank_Auto_Generated TEXT,
Clickbank_Language TEXT,
Clickbank_Font_Color TEXT,
Clickbank_Link_Color TEXT,
Clickbank_Link_Hover_Color TEXT,
Clickbank_Link_Check TEXT,
Ebay_Auto_Generated TEXT,
Ebay_Link_Check TEXT
);
");
$createcontextuallinksettingstable->execute();

?>

If I remove all entries after main path it create the table, why does it do this. If I remove everything after Main_Path TEXT it creates the table why?

3
  • 1
    do you get an error? Commented Oct 6, 2014 at 23:02
  • no no error recieved Commented Oct 6, 2014 at 23:03
  • MySQL issued an error. The PHP code doesn't check the return, it's ignoring the error that was raised. With PDO error mode set to throw exceptions, very likely the error would have been received. http://php.net/manual/en/pdo.error-handling.php Commented Oct 6, 2014 at 23:40

1 Answer 1

1

SQL Error 1060. Duplicate column name.

You have duplicated Use_Monetizer column there.

For long statements like this - consider using some tool that helps in SQL.

If you have database on your localhost - MySQL Workbench is probably best idea.

If you are using some hosting server - it probably has PHPMyAdmin installed.

And you should learn using PHP with MySQL. You probably don't even know how to read error message.

You can start learning here: PHP Academy on Youtube

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.