Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Error in your SQL syntax

    Hello,

    I would like to get help with my PHP/SQL code. I am receiving an error stating: ERROR in INSERT QUERY : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''206','0','F','W','Dcal','SuheMehdisUivesiy','Psychlgy','3.4','370','560','0','0' at line 1

    I am using PHP version 5.2.10.

    It may have something to do with the single quotes.
    Below is the php code
    [PHP]
    <html><head><title>Assignment 2</title></head> <body>
    Finished.<br>

    PHP Code:
    <html><head><title>Assignment 2</title></head> <body>
    Finished.<br>

    <?php

        
    include_once("dbconnect.inc.php");
        
    $ip getenv("REMOTE_ADDR");
        
        
        
    $delimeter $_GET["delimiter"];
        
    $file fopen($FileDestination"r");
        
        if (!
    $file
        {
            echo 
    "<p>Unable to open remote file.\n";
            exit;
        }
        
        
        if (!
    feof($file)) 
        {
            
    $line fgets($file);
            
    //echo "$line <br>";
            
    $string str_replace(array("\n""\r"), ''$line);
            
    //echo "$string <br>";
            
    $fields explode($delimeter$string);
            
    //echo "$fields <br>";
         
    }
        
        
    $datatypes = array(); $datatypesX = array();
        echo 
    count($fields);$c=1;
        
        for(
    $i=0;$i<count($fields);$i++)
            {
            
    $datatypes $_GET["type".$c];
            
            if(
    $datatypes[$i] == "nominal")
                
    $datatypesX[$i]  = "varchar(255)";
            else if(
    $datatypes[$i] == "decimal")
                
    $datatypesX[$i]  = "DECIMAL(60,2)";
            else 
                
    $datatypesX[$i]  = "INT";
                
    $c=$c+1;
            }


        
    mysql_query("DROP TABLE IF EXISTS CPSC862");
        
        
    $sql "CREATE TABLE CPSC862(ApplicationID int NOT NULL, PRIMARY KEY (ApplicationID), ";
        
    //echo $Attributesarray[1];
        //echo $sql;
        
    for($i=0;$i<count($fields);$i++) 
        {
            
    $fields[$i] = trim($fields[$i]);
            
    //$key = str_replace(" ", "_", $key);
            //echo $fields[$i] ." ". $datatypesX[$i];
            
    if($i != count($fields) - 1)
                
    $sql .= " " $fields[$i] . " " $datatypesX[$i] . ", "
            else
                
    $sql .= " " $fields[$i] . " " $datatypesX[$i] ; 
                
        
        }
            
        
    //$sql = substr($sql, 0, strlen($sql)-2);
        
    $sql .= ");";
        
    //echo "SQL statement : " . $sql . "<br>";
        
    $result mysql_query($sql);
        echo 
    "Table has been created..";
        
        if (!
    $result
        {
            echo 
    "ERROR in CREATE TABLE QUERY : " mysql_error() . "<br>";    
        }
        
        
    $i=0;
        
    $count=0;
        
    $TableRows= array();
        
    //Create the tablerows line by line Tablerows = 207
        
    while (!feof($file))  
        {
            
    $line fgets($file);
            
    $TableRows[$count]=$line;
            
    //echo $TableRows[$i];
            //echo "<br>";
            
    $count++;
        }

        
    //echo "count is" . $count;
        //create columns/fields
        
    $t count($fields); //13
        
    for ($i=0$i<$t$i++) 
        {
            echo 
    $fields[$i];
            echo 
    "<br>";
            if (
    $i == $t-)
            {
                
    $column .= "" $fields[$i];
            }    
            else {
                
    $column .=  " " $fields[$i] . ", ";
                }    
        }
            
        
    //echo $column;
        
    $statement"Insert into CPSC862 (ApplicationID, " $column;
        
    $m =count($TableRows); echo $m//m=207
        
    echo "<br>";
        
    $valuestatement ") values ";
        
    //append to rest of statement
        
    $statement .=  $valuestatement ;
        
    //echo $statement;
        
    $row = array(); 
            
        for (
    $i=0$i<$m$i++)      {            
                
    //echo $TableRows[$i];
                
    $row[$i] = str_replace(",","%",$TableRows[$i]);
                
    $row[$i] = explode($delimeter$TableRows[$i]);            
                }
                        

                
        for (
    $i=0$i<$m$i++) //do while i 206 < 207
        
    {
            
    $statement =  "('" .$i;
            
    $statement .= "',";
            
    $k count($row[$i]);
            
    //echo $k . "k equals";13             
                
    for ($j=0$j<$k$j++) //loop until j 12 < k13 This creates the other values
                

                        if (
    $j==$k-1) {    
                                    
                            
    $insert $row[$i][$j]; 
                            
    $statement.= "'".$insert;
                            
    $statement=trim($statement);
                            
    $statement.="')";

                        }    
                        
                        else {
                            
    $insert $row[$i][$j]."'";
                            
    $statement .= "'" .$insert.",";
                        }
                }                
                                    
    //echo $statement;
        
    }    $statement .= ";";
            echo 
    $statement;

            
    $result mysql_query($statement);
            
            if (!
    $result) {
                echo 
    "ERROR in INSERT QUERY : " mysql_error() . "<br>";    
                }
            
            echo 
    "File Contents Uploaded to Database <br>";
            
    fclose($file);

    ?>
    </body></html>
    ('206','0','F','W','Dcal','SuheMehdisUivesiy','Psychlgy','3.4','370','560','0','0','0','0');ERROR in INSERT QUERY : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''206','0','F','W','Dcal','SuheMehdisUivesiy','Psychlgy','3.4','370','560','0','0' at line 1
    Here is how the txt file looks
    Code:
    CITIZENSHIP	GENDER	Race	DEGREE	INST1	INST1_MAJOR	O_INST1_GPA	O_GRE_V	O_GRE_Q	O_TOEFL_SCORE	PERM_CITY	PERM_STATE	PERM_ZIP
    IN	M	B	Mase	ChisCllege	Psychlgy	0	470	640	253	IBKJayaaga	0	560011
    IN	F	O	Dcal	MiesaSaeUivesiy,Maka	IdusialOgaizaialPsychlgy	4	470	640	0	Maka	0	56001
    C1	F	W	Dcal	UivesiyfCalgay	Psychlgy	0	600	700	0	Calgay	0	T3E6L5
    WE	M	N	Dcal	NewYkUivesiy	RehabiliaiCuselig	3.5	320	580	257	Washig	0	20036
    KS	F	N	Dcal	KeaUivesiy	EglishEducaiadPsychlgy	0	670	780	260	Seul	0	153013
    TW	F	O	Dcal	UivesiyfRhdeIslad	SchlPsychlgy	0	370	740	223	Tay	0	334
    IN	F	O	Dcal	IVERSITYOFMUMBAI	PSYCHOLOGY	0	380	700	263	THANEWEST	0	400602
    RO	F	N	Dcal	Al.I.CuzaUivesiy	Psychlgy	0	570	620	247	0	0	0
    US	F	N	Dcal	TheUivesiyfTeesseeaMaiMaiT	Psychlgy	3.9	460	470	0	Claksville	TN	37043
    US	F	O	Dcal	UivesiyfAlama	Psychlgy	3.8	570	590	0	Nhp	AL	35473
    US	M	W	Dcal	LipscmbUivesiy	Psychlgy	3.7	600	660	0	Meplis	IL	62960
    US	F	W	Dcal	uivesiyfflida	psychlgy	2.9	330	600	0	miami	FL	33176
    US	M	W	Dcal	HueCllege	Psychlgy	3.7	520	580	0	Flushig	NY	11365
    US	F	W	Dcal	YugswSaeUivesiy	Psychlgy	3.4	490	630	0	Wae	OH	44483
    US	F	B	Dcal	DilladUivesiy	Psychlgy	3.6	480	660	0	Memphis	TN	38115
    US	M	W	Dcal	MississippiSaeUivesiy	Psychlgy	3.5	650	260	0	Sakville	MS	39759
    US	F	W	Dcal	FlidaSaeUivesiy	Psychlgy	4	570	560	0	Tallahassee	FL	32308
    US	F	O	Dcal	TheUivesiyfGegia	Psychlgy	3.8	530	710	0	Laweceville	GA	30044
    US	F	W	Dcal	MiesaSaeUivesiy,Maka	Psychlgy	3.9	450	550	0	Blmig	MN	55438
    US	M	W	Dcal	SaJseSaeUivesiy	Psychlgy	3.7	640	500	0	Reddig	CA	96001
    US	F	W	Dcal	UivesiyfAkasas	Psychlgy	3.8	380	620	0	Jesb	AR	72401
    US	F	W	Dcal	ChisiaBhesUivesiy	Psychlgy	3.6	410	510	0	Memphis	TN	38107
    US	F	W	Dcal	UivesiyfAkasas	Psychlgy	3.8	380	480	0	LileRck	AR	72212
    US	F	W	Dcal	ClemsUivesiy	Psychlgy	3.5	480	670	0	Chale	NC	28270
    US	F	H	Dcal	VadebilUivesiy	ClaiePefmaceadPsychlgy	3.3	550	690	0	TheWdlads	TX	77381
    US	M	W	Dcal	S.AdewsPesbyeiaCllege	PsychlgyadPhilsphy	3.6	640	480	0	Spigfield	VA	22153
    US	M	W	Dcal	MillesvilleUivesiy	ClicalPsychlgy	4	610	490	0	Lacase	PA	17602
    US	F	N	Dcal	SpigHIllCllege	Psychlgy	3.5	440	560	0	Mbile	AL	36609
    US	F	W	Mase	UivesiyfAlamaaBimigham	Psychlgy	3.3	360	420	0	Bimigham	AL	35209
    US	F	W	Mase	GadsdeSaeCmmuiyCllege	0	3.6	360	510	0	Suhside	AL	35907
    US	F	W	Mase	TulaeUivesiy	Psychlgy	2.9	330	630	0	Miami	FL	33133
    US	M	W	Dcal	GulfCasCmmuiyCllege	Psychlgy	3.7	540	610	0	Gaiesville	FL	32606
    US	M	H	Dcal	SeHallUivesiy	CuseligPsychlgy	3.8	420	610	0	Ak	OH	44304
    US	F	H	Mase	AubuUivesiy	Psychlgy	3.8	480	570	0	Idiaaplis	IN	46220
    US	F	W	Dcal	LychbugCllege	PSy	3.2	530	600	0	Rchese	NY	14610
    US	F	O	Mase	NaialChugHsigUivesiy	ScialWk	0	300	620	0	Opelika	AL	36801
    US	F	W	Mase	UivesiyfFlida	Psychlgy	3.8	410	670	0	PSLucie	FL	34984
    US	M	W	Mase	UahSaeUivesiy	Psychlgy	3.4	630	560	0	Aubu	AL	36830
    US	F	W	Mase	SamfdUivesiy	PsychlgyadSpaish	0	400	480	0	Bimigham	AL	35210
    US	M	W	Dcal	UivesiyfGegia	Psychlgy	3.2	490	600	0	Maiea	GA	30066
    US	F	W	Dcal	IwaCealCmmuiyCllege	HighSchlDlCediCuses	4	460	720	0	WebseCiy	IA	50595
    US	F	B	Dcal	PiceUivesiy	Psychlgy	2.7	530	480	0	Bkly	NY	11205
    US	F	W	Dcal	UivesiyfMiss	Psyc	3.1	390	570	0	Maiea	GA	30066
    US	F	B	Dcal	GambligSaeUivesiy	Psychlgy	3.8	410	580	0	Meidia	MS	39301
    US	F	W	Mase	UivesiyfFlida	Psychlgy	3.5	450	620	0	NewPRichey	FL	34653
    US	M	W	Dcal	MacaleseUivesiy	Psychlgy	3.3	510	660	0	SaiPaul	MN	55105
    US	M	W	Dcal	MississippiSaeUivesiy	Psychlgy	3.3	520	590	0	Sakville	MS	39759
    US	F	W	Dcal	TexasTechUivesiy	Psychlgy	3.5	460	730	0	Yacey	TX	78886
    US	F	W	Dcal	UivesiyfMIchiga	Psychlgy	0	350	550	0	DeabHeighs	MI	48125
    US	F	W	Dcal	MississippiSaeUivesiy	Psychlgy	3.8	550	590	0	Sha	MS	38868
    US	F	W	Dcal	WeseKeuckyUivesiy	PsychlgyadScilgy	3.5	440	510	0	Vesailles	KY	40383
    US	M	W	Dcal	UivesiyfMississippi	Psychlgy	2.9	510	630	0	Amy	MS	38821
    US	M	I	Dcal	BlackHillsSaeUiv.	Psychlgy	3.1	460	560	0	Hve	AL	35244
    US	F	W	Dcal	TeesseeTechlgicalUivesiy	Psychlgy	3.3	500	590	0	Gaiesb	TN	38562
    US	F	W	Dcal	BadleyUivesiy	Psychlgy	4	490	560	0	CeveCeu	IL	61610
    US	F	W	Dcal	UivesiyfFlida	Psychlgy	3.7	520	480	0	WieHave	FL	33880
    0	F	N	Dcal	UivesiyfTulsa	IdusailOgaizaiPsyclgy	3.7	460	530	0	Tulsa	OK	74119
    0	M	B	Dcal	RhdesCllege	PsychlgyadPhilsphy	2.5	470	600	0	Alaa	GA	30331
    0	F	N	Dcal	Uiv.fMissuiaK.C.	a	4	570	570	0	KasasCiy	MO	64131
    0	F	N	Dcal	UivesiyfAlama	Psychlgy	3.6	580	650	0	She	AL	36075
    0	F	H	Dcal	TuskegeeUiv.	Psy	2.9	400	430	0	Tampa	FL	33626
    0	F	N	Dcal	CapeFeaCmmuiyCllege	LibealAsAssc.	3.7	550	560	0	Wilmig	NC	28409
    0	M	W	Dcal	UivesiyfCealFlida	SchlPsychlgy	4	460	450	0	WiePak	FL	32792
    0	M	W	Dcal	TeesseeTechUiv.	Psychlgy	3.7	630	600	0	Ckeville	TN	38501
    0	F	W	Dcal	OhiUivesiy	Psychlgy	3.6	630	550	0	Hllad	OH	43528
    0	F	B	Dcal	Uiv.fMemphis	Psy	3.6	620	490	0	Miami	FL	38115
    0	F	W	Dcal	VadebilUivesiy	PsychlgyadChildDevelpme	3	570	520	0	SaaClaus	IN	47579
    0	M	W	Dcal	Uiv.NhFl	Psy	3.7	400	580	0	Jacksville	FL	32256
    0	F	W	Dcal	AubuUiv	Psy	3.9	500	540	0	Husville	AL	35801
    0	F	W	Dcal	UivesiyfVigiia	Psychlgy	3.5	550	750	0	Salem	VA	24153
    0	M	W	Dcal	SamHusSaeUivesiy	Psychlgy	3.6	620	690	0	Husville	TX	77340
    0	F	W	Dcal	Uiv.fCealFL	Psy	3.6	510	520	0	Davie	FL	33325
    0	M	W	Dcal	UiedSaesIeaialUiv.	IdusialOgaizaialPsy	3.9	600	700	0	Aveua	FL	33180
    0	F	N	Dcal	PeppedieUivesiy	Psychlgy	3.9	510	540	0	Mpak	CA	93021
    0	F	W	Dcal	RllisCllege	Psychlgy	3.7	580	620	0	LakeWh	FL	33463
    0	F	W	Dcal	NheIlliisUivesiy	0	3.7	590	670	0	Whea	IL	60187
    0	F	B	Dcal	SPELMANCOLLEGE	PSYCHOLOGY	3.7	580	590	0	CHINOHILLS	CA	91709
    0	M	W	Dcal	SpigHillCllege	PsychlgyadTheae	0	570	480	0	Meaiie	LA	70001
    0	M	W	Dcal	UahSaeUivesiy	Psychlgy	3.8	480	580	0	Lewis	UT	84320
    0	F	W	Dcal	WffdCllege	PsychlgyadGveme	3	490	570	0	Raleigh	NC	27615
    US	F	W	Dcal	NewYkUivesiy	Psychlgy	4	610	590	0	Blmig	IN	47408
    0	F	W	Dcal	AlamaSuheCmmuiyClege	asfe	0	520	490	0	Tuscalsa	AL	35405
    0	F	W	Dcal	UCLA	Psychlgy	4	640	680	0	Campbell	CA	95008
    0	F	W	Dcal	WeseCaliaUivesiy	CliicalPsychlgy	3.7	510	450	0	FeadiaBeach	FL	32034
    US	F	W	Dcal	WideeUivesiy	Psychlgy	3.7	540	650	0	As	PA	19014
    US	F	N	Dcal	AubuUivesiy	Psychlgy	3	390	380	0	Besseme	AL	35020
    US	F	W	Dcal	UivesiyfGegia	Psychlgy	3.8	600	640	0	Ahes	GA	30606
    US	F	W	Dcal	UivesiyfGegia	Psychlgy	3.9	530	640	0	Ahes	GA	30605
    US	F	W	Dcal	FiedsUivesiy	BilgicalSciecesadPemedicalsudies	2.9	550	560	0	Wichia	KS	67212
    US	F	W	Dcal	AubuUivesiy	Psychlgy	3.9	500	570	0	Opelika	AL	36801
    US	F	W	Dcal	MississippiUivesiyfWme	Psychlgy	3.8	430	490	0	Ackema	MS	39735
    US	M	W	Dcal	FaulkeSaeC.C.	ScialSciece	3.4	360	500	0	OageBeach	AL	36561
    US	F	W	Dcal	Uiv.fMississippi	Psychlgy	3.4	390	420	0	Jacks	MS	39211
    US	F	W	Dcal	UivesiyfTeessee	Psychlgy	3.8	540	560	0	Chaaga	TN	37421
    US	F	W	Dcal	UuvesiyTeessee,Chaaga	ReseachPsych	3.9	480	480	0	Chaaga	TN	37411
    US	F	W	Dcal	UivesiyfIdiaaplis	Psychlgy	3.9	660	680	0	Geefield	IN	46140
    US	F	N	Dcal	EmyUivesiy	Psychlgy	2.7	440	550	0	Bx	NY	10475
    US	F	W	Dcal	CllegefS.Beedic	Psychlgy	3.8	590	730	0	NewUlm	MN	56073
    US	F	W	Dcal	UivesiyfAlama	Psychlgy	3.1	390	460	0	Mgmey	AL	36111
    US	F	W	Dcal	FlidaSaeUivesiy	Psychlgy	0	420	590	0	OagePak	FL	32065
    US	F	B	Dcal	SaDiegSaeUivesiy	DevelpmealPsychlgy	3.7	470	650	0	Tusi	CA	92780
    US	F	W	Dcal	NichllsSaeUivesiy	Psychlgy	4	510	550	0	Thibdaux	LA	70301
    US	F	W	Dcal	RsevelUivesiy	CliicalPsychlgy	4	570	520	0	Racie	WI	53406
    US	F	W	Dcal	LuisiaaSaeUivesiy	Psychlgy	0	550	620	0	BaRuge	LA	70810
    US	F	W	Dcal	UivesiyfFlida	Psychlgy	3.2	560	590	0	Gaiesville	FL	32608
    US	F	W	Dcal	CealMichigaUivesiy	Psychlgy	3.9	520	640	0	Shephed	MI	48883
    US	F	W	Dcal	MiddleTeesseeSaeUivesiy	CliicalPsychlgy	3.9	530	570	0	Mufeesb	TN	37128
    US	F	W	Dcal	SuheaseLuisiaaUivesiy	Geeal/eimealPsychlgy	3.9	450	520	0	Reseve	LA	70084
    US	M	W	Dcal	UivesiyfTN@Chaaga	Psychlgy	3.4	380	450	0	Chaaag	TN	37415
    US	M	W	Dcal	MashallUivesiy	I/OPsychlgy	3.7	520	450	0	Huig	WV	25704
    US	F	W	Dcal	MississippiSaeUivesiy	CliicalPsychlgy	3.8	430	620	0	Kigsp	TN	37663
    US	M	W	Dcal	UievesiyfAlama	Psychlgy	0	430	630	0	MuscleShals	AL	35661
    US	M	W	Dcal	XavieUivesiy	PeMed	3.4	520	730	0	Maieville	OH	45039
    US	F	N	Dcal	UivesiyfNda,Re	Psychlgy&EglishLieaue(DlMaj)	3.9	620	640	0	Re	NV	89503
    US	F	W	Dcal	FlidaSaeUivesiy	PsychlgyadReligi	3.9	570	680	0	OmdBeach	FL	32176
    US	F	W	Dcal	MiddleTeesseeSaeUivesiy	Psychlgy,Pegadecceai	3.9	530	620	0	Mufeesb	TN	37130
    US	M	W	Dcal	UWEauClaie	PsychlgyadOgaizaialCmmuicais	2.9	410	550	0	EauClaie	WI	54703
    US	F	W	Dcal	MillesvilleUivesiy	Psychlgy	3.7	550	590	0	Lacase	PA	17603
    US	F	W	Dcal	WashigUivesiy	Bilgy	3.9	570	740	0	CwPi	IN	46307
    US	F	W	Dcal	RakeCllege	Psychlgy/Mahemaics	3.5	550	570	0	VillaRica	GA	30180
    US	F	W	Dcal	SuhwesMissuiSaeUivesiy	Psychlgy	3.7	600	550	0	Jacks	MO	63755
    US	M	B	Dcal	FlidaA&MUivesiy	BusiessAdmiisai	2.3	520	580	0	Maiea	GA	30067
    US	M	W	Dcal	SuheIlliisUivesiyaCabdale	Psychlgy	3.1	680	690	0	Aa	IL	62906
    US	F	B	Dcal	XavieUivesiyfLuisiaa	Psychlgy	0	460	590	0	NewOleas	LA	70126
    US	F	H	Dcal	FlidaIeaialUivesiy	Psychlgy	3.6	510	610	0	Hialeah	FL	33013
    US	F	W	Dcal	MeedihCllege	Psychlgy	3.5	480	620	0	Ede	NC	27288
    US	M	W	Dcal	UivesiyfSuhFlida	Psychlgy	3.8	480	610	0	Tampa	FL	33624
    US	F	N	Dcal	TheGegeWashigUivesiy	Psychlgy	3	470	460	0	Alaa	GA	30350
    US	F	W	Dcal	UivesiyfOeg	Psychlgy	3.6	550	740	0	Eugee	OR	97408
    US	M	W	Dcal	BuckellUivesiy	Psychlgy	3.4	560	620	0	Haisbug	PA	17112
    US	F	B	Dcal	MIssissippiSaeUivesiy	Psychlgy	3.8	360	580	0	Pace	MS	38764
    US	M	W	Dcal	SpigHillCllege	Mahemaics	2.9	480	740	0	Mbile	AL	36695
    0	F	W	Dcal	GACllege&SaeUivesiy	Psy.	3.5	500	420	0	0	0	0
    0	F	B	Dcal	ClakAlaaUivesiy	Psychlgy	0	480	590	0	0	0	0
    0	F	W	Dcal	LusiaaSaeUivesiy	Psychlgy	0	450	600	0	0	0	0
    0	F	B	Dcal	PeppedieUivesiy	0	0	350	500	0	0	0	0
    0	F	W	Dcal	AubuUivesiyMgmey	JusiceadPublicSafey	4	390	450	0	0	0	0
    0	F	B	Dcal	DepauwUivesiy	psychlgy	0	450	440	0	0	0	0
    0	F	N	Dcal	GegeWashigUivesiy	MaealadChildHealh	0	510	730	0	0	0	0
    0	F	W	Dcal	PeSaeUivesiy	Psychlgy	0	480	500	0	0	0	0
    US	F	N	Mase	AubuUivesiy	Psychlgy	3	390	380	0	Besseme	AL	35020
    US	F	W	Dcal	MeedihCllege	PsychlgyadSpaish	3.7	670	630	0	Geeville	NC	27858
    US	F	B	Dcal	AgesScCllege	Psychlgy	3	480	360	0	SeMi	GA	30083
    US	F	W	Dcal	UivesiyfWIMilwaukee	Psychlgy	3.7	610	650	0	Milwaukee	WI	53211
    US	F	W	Dcal	ClliCuyCmmuiyCllege	Busiess	2.9	410	540	0	RyseCiy	TX	75189
    US	F	W	Dcal	LycmigCllege	PsychlgyadBusiessAdmiisai	3.8	480	580	0	Buffal	NY	14216
    US	F	W	Dcal	TySaeUivesiy	Psychlgy	4	460	360	0	Fs	GA	30241
    US	F	W	Dcal	DuyUivesiy	PsychlgyadSpaish	3.9	550	710	0	Sedalia	0	65301
    US	F	H	Dcal	PeppedieUivesiy	CliicalPsychlgy	3.9	610	570	0	Kewd	MI	49508
    US	M	W	Dcal	WeseMichigaUivesiy	PsychlgyadAppliedSaisics	3.2	350	510	0	Kalamaz	MI	49008
    US	F	W	Dcal	AubuUivesiy	Psychlgy	3	430	550	0	Mbile	AL	36695
    US	F	W	Dcal	ValeciaCmmuiyCllege	GeealSudies	2.9	380	520	0	Olad	FL	32822
    US	F	W	Mase	HuigdCllege	Bilgy	0	510	610	0	Wilme	AL	36587
    US	F	O	Mase	BeijigUivesiyfPhysicalEducai	Bimechaics	3.2	310	690	227	Jacksville	AL	36265
    US	F	W	Mase	KeSaeUivesiy	Psychlgy	2.9	450	410	0	Bedfd	OH	44146
    0	M	W	Dcal	SaeUivesiyfNewYkaClad	Psychlgy	3.2	470	630	0	0	0	0
    0	F	W	Dcal	FlidaSaeUivesiy	Psychlgy	3.8	780	710	0	Alaa	GA	30306
    0	M	W	Dcal	SamfdUivesiy	Psychlgy	3.7	540	730	0	Hve	AL	35242
    0	F	H	Dcal	UivesiyfGegia	PsychlgyadSpaish	3.3	390	610	0	Maiez	GA	30907
    0	M	W	Dcal	LeeUivesiy	Psychlgy	3.8	540	570	0	0	0	0
    0	F	O	Dcal	ClumbiaUivesiy,BaadCllege	Psychlgy	3.2	550	690	0	0	0	0
    0	F	W	Dcal	ChisiaBhesUiv.	Psy	3.9	530	670	0	0	0	0
    0	F	W	Dcal	GaUivesiy	Psy	3.8	600	500	0	0	0	0
    0	M	W	Dcal	ClemsUvesiy	Psy	3.9	740	640	0	Saye	PA	18840
    0	M	W	Dcal	EasTeesseeSaeU.	CliicalPsychlgy	0	620	610	0	Elizabeh,	TN	37643
    0	F	W	Dcal	EasTeesseeSaeUivesiy	CliicalPsychlgy	3.9	560	660	0	Kigsp	TN	37664
    0	F	W	Dcal	OklahmaSaeUivesiy	Psychlgy	3.7	500	710	0	Muskgee	OK	74403
    0	F	W	Dcal	GuilfdCllege	Psy	3.5	560	620	0	Geesb	NC	27455
    0	M	W	Dcal	AlamaSaeUivesiy	Psychlgy	3.9	490	600	0	Mgmey	AL	36117
    0	F	W	Dcal	SzczeciUivesiy	PlishSudies/Teachig	3.9	570	620	0	APO	AE	9889
    0	F	W	Dcal	UivesiyfMississippi	Psychlgy	3.5	400	510	0	Bad	MS	39047
    0	F	W	Dcal	UivesiyfNhCalia	Psychlgy	0	630	730	0	WisSalem	NC	27104
    0	F	W	Dcal	UivesiyfCalifia,LsAgeles	Geeal	3.3	470	710	0	HuigBeach	CA	92648
    0	M	W	Dcal	AppalachiaSaeUivesiy	CliicalPsy	3.5	350	620	0	Be	NC	28607
    US	F	W	Dcal	UivesiyfCecicu	Psychlgy	3.5	370	440	0	Nwalk	CT	6855
    0	M	W	Dcal	UahSaeUivesiy	Psychlgy	3.6	630	560	0	Richfield	UT	84701
    US	M	W	Dcal	UivesiyfSuhAlama	AppliedPsychlgy	3.9	480	580	0	Mbile	AL	36606
    US	M	W	Dcal	UivesiyfKasas	HumaBilgy	3.4	520	570	0	Hays	KS	67601
    US	F	W	Dcal	FlidaSaeUivesiy	Psychlgy	3.9	460	540	0	GulfBeeze	FL	32561
    US	F	W	Dcal	NheKeuckyUivesiy	Udeclaed	3.3	530	580	0	Lexig	KY	40517
    US	F	H	Dcal	ClaemMcKeaCllege	PsychlgyadBilgy	3.7	540	750	0	Buk	CA	91504
    US	F	W	Dcal	UivesiyfAlamaaBimigham	psychlgy	3.4	460	460	0	Hve	AL	35244
    US	M	O	Dcal	CChapelHill	Psychlgy	3.4	550	570	0	Chale	NC	28277
    US	M	W	Dcal	S.OlafCllege	Psy	3.6	560	670	0	Midlhia	VA	23112
    US	F	I	Dcal	SuheAdveisUivesiy	Psychlgy	3.8	490	540	0	Cllegedale	TN	37315
    US	F	W	Dcal	LycmigCllege	PsychlgyadEglish	3.8	600	780	0	Behlehem	PA	18020
    US	M	W	Dcal	UivesiyfSuhAlama	Psychlgy	3.3	470	580	0	Mbile	AL	36605
    US	F	O	Dcal	UivesiyfFlida	Psychlgy	3.6	460	500	0	SuhVeice	FL	34293
    US	F	W	Dcal	EaseMichigaUivesiy	Psychlgy	3.6	500	440	0	Tled	OH	43606
    US	F	W	Dcal	UivesiyfSuhAlama	Psychlgy	3.3	490	510	0	Mbile	AL	36609
    US	F	W	Dcal	EasCealCllege	Psychlgy	2.1	430	530	0	Clumbia	MO	65202
    US	F	W	Dcal	UivesiyfMemphis	Psychlgy	3.6	510	380	0	Bale	TN	38134
    US	M	B	Dcal	RhdesCllege	PsychlgyadPhilsphy	2.5	470	600	0	Alaa	GA	30331
    US	F	W	Dcal	IwaSaeUivesiy	Psychlgy	3.9	430	690	0	Kigsley	IA	51028
    US	M	W	Dcal	EasCaliaUivesiy	CliicalPsychlgy	3.9	620	720	0	Geeville	NC	27834
    US	F	I	Dcal	KeesawSaeUivesiy	Psychlgy	3.4	520	430	0	Dallas	GA	30157
    US	F	B	Dcal	LuisiaaSaeUivesiy	Psychlgy	3.2	450	590	0	Plaquemie	LA	70764
    US	F	W	Dcal	UivesiyfFlida	psychlgy	3	600	690	0	Olad	FL	32819
    0	F	W	Dcal	CWILMINGTON	PSYCHOLOGY	0	550	600	0	0	0	0
    0	F	B	Dcal	SPELMANCOLLEGE	PSYCHOLOGY	0	470	560	0	0	0	0
    0	F	W	Dcal	SOUTHERNMETHODISTIVERSITY	PSYCHOLOGY	0	650	610	0	0	0	0
    0	F	W	Dcal	SaJseSaeUivesiy	Psychlgy	3.6	490	480	0	0	0	0
    0	F	W	Dcal	EaseMichigaUivesiy	Psychlgy	4	600	610	0	0	0	0
    0	F	W	Dcal	Uiv.fNebaska	Psychlgy	3.9	540	560	0	0	0	0
    0	F	W	Dcal	MichigaSaeUivesiy	PeLawCgaeiPsy	3.7	420	510	0	0	0	0
    0	F	W	Dcal	UivesiyfFlida	Psychlgy	3	570	560	0	0	0	0
    0	F	W	Dcal	SuheMehdisUivesiy	Psychlgy	3.4	370	560	0	0	0	0
    I know this is a lot of information but I didn't want to leave anything out. Thanks for your help.

  • #2
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fyi

    also i think it is running the last entry in twice but i cant find this problem anywhere in my code. Thanks

  • #3
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I lied. Its not inserting twice. I had my echo statements set up funny.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The error itself pretty much screams of a datatype mismatch, but I don't know why it appears to make it to the last.
    Needless to say, this is way, WAY too much work. You're dropping and creating a table on every run, but that doesn't make any sense. You can eject the data with a TRUNCATE or DELETE query. You could use an autoincrement as well for the primary.
    This uses some pretty old stuff as well. MySQL library shouldn't be used, use the mysqli or PDO instead. These work far better with batch prepared statements anyway.
    PHP Code:
    $mysqli = new MySQLi('...');
    if (
    $stmt $mysqli->prepare('INSERT INTO mytable VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)'))
    {
        
    $stmt->bind_param('isssssdiiiiii',
            
    $a$b$c$d$e$f$g$h$i$j$k$l$m);
        while (
    false !== ($in fgetcsv($file1000"\t")))
        {
            if (
    $in != null)
            {
                list(
    $a$b$c$d$e$f$g$h$i$j$k$l$m) = $in;
                
    $stmt->execute();
            }
        }
        
    $stmt->close();

    You'd have to skim the first line out of the CSV (and also assumes its a valid CSV).

    Untested, works okay in my head. It doesn't cover everything you have, but since this is an assignment I probably shouldn't just give you an entire solution.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,080
    Thanks
    2
    Thanked 321 Times in 313 Posts
    When you echoed your query statement, did you happen to notice that it is missing the first part of the query syntax (hint: you are missing a concatenation dot . in your code.)
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •