dsaba Posted March 22, 2007 Share Posted March 22, 2007 i make a success or error statement on a query I do if the query is == 1, then it is successful OR i also tried if the query == TRUE it keeps giving me my error message, so I echoed all the variables in the query to see if they exist, and they do, you will see my code below <?php $query1 = 'INSERT INTO `mainfilelist` ( `filename_en`, `filegeneraltype_en`, `filegeneraltype_he`, `filegeneraltype_es`, `filegeneraltype_pt`, `filegeneraltype_pl`, `filespecifictype_en`, `filespecifictype_he`, `filespecifictype_es`, `filespecifictype_pt`, `filespecifictype_pl`, `fileifwalla`, `fileifyahoo`, `fileifgmail`, `fileiflycos`, `filenumwalla`, `filenumyahoo`, `filenumgmail`, `filenumlycos`, `filetotalmirrors`, `filewhatmirrors`, `filelanguage_en`, `filelanguage_he`, `filelanguage_es`, `filelanguage_pt`, `filelanguage_pl`, `fileifpassword_en`, `fileifpassword_he`, `fileifpassword_es`, `fileifpassword_pt`, `fileifpassword_pl`, `filepassword`, `filetemplateid`, `filesubmitlang`, `fileusername`, `fileuserip`, `filestatus_en`, `filestatus_he`, `filestatus_es`, `filestatus_pt`, `filestatus_pl`, `filestatusimage`, `filesentfrom`, `filedateadded`, `filedatetime`, `filehash1`, `filehash2`, `filedescription_en`, `fileimageurl1`, `fileimageurl2`, `fileimageurl3` ) VALUES ( '.$filename.','.$transgeneraltype_en.','.$transgeneraltype_he.','.$transgeneraltype_es.','.$transgeneraltype_pt.','.$transgeneraltype_pl.','.$transspecifictype_en.','.$transspecifictype_he.','.$transspecifictype_es.','.$transspecifictype_pt.','.$transspecifictype_pl.','.$fileifwalla.','.$fileifyahoo.','.$fileifgmail.','.$fileiflycos.','.$filenumwalla.','.$filenumyahoo.','.$filenumgmail.','.$filenumlycos.','.$filetotalmirrors.','.$filewhatmirrors.','.$transfilelanguage_en.','.$transfilelanguage_he.','.$transfilelanguage_es.','.$transfilelanguage_pt.','.$transfilelanguage_pl.','.$transifpassword_pt.','.$transifpassword_pl.','.$filepassword.','.$filetemplateid.','.$userlanguage_en.','.$fileusername.','.$fileuserip.','.$transfilestatus_en.','.$transfilestatus_he.','.$transfilestatus_es.','.$transfilestatus_pt.','.$transfilestatus_pl.','.$filestatusimage.','.$filesentfrom.','.$date.','.$datetime.','.$filehash1.','.$filehash2.','.$filedescription.','.$fileimageurl1.','.$fileimageurl2.','.$fileimageurl3.' )'; $runquery1 = mysql_query( $query1 ); if ($runquery1 == 1) { echo( "the table mainfilelist HAS BEEN succesfully INSERTED.<br>"); } else { mysql_close(); die('ERROR: mainfilelist has NOT BEEN inserted <br><br>'.$query1); } ?> this is the error message that keeps coming up and also where I echo the variables of the query as you can see there is NO INSTANCE of ,, meaning its all filled in ERROR: mainfilelist has NOT BEEN inserted INSERT INTO `mainfilelist` ( `filename_en`, `filegeneraltype_en`, `filegeneraltype_he`, `filegeneraltype_es`, `filegeneraltype_pt`, `filegeneraltype_pl`, `filespecifictype_en`, `filespecifictype_he`, `filespecifictype_es`, `filespecifictype_pt`, `filespecifictype_pl`, `fileifwalla`, `fileifyahoo`, `fileifgmail`, `fileiflycos`, `filenumwalla`, `filenumyahoo`, `filenumgmail`, `filenumlycos`, `filetotalmirrors`, `filewhatmirrors`, `filelanguage_en`, `filelanguage_he`, `filelanguage_es`, `filelanguage_pt`, `filelanguage_pl`, `fileifpassword_en`, `fileifpassword_he`, `fileifpassword_es`, `fileifpassword_pt`, `fileifpassword_pl`, `filepassword`, `filetemplateid`, `filesubmitlang`, `fileusername`, `fileuserip`, `filestatus_en`, `filestatus_he`, `filestatus_es`, `filestatus_pt`, `filestatus_pl`, `filestatusimage`, `filesentfrom`, `filedateadded`, `filedatetime`, `filehash1`, `filehash2`, `filedescription_en`, `fileimageurl1`, `fileimageurl2`, `fileimageurl3` ) VALUES ( fsadfsdf,Music,Muzika,Musica,Musica,pl for music,PSP Movie,he for psp movie,es for psp movie,pt for psp movie,pl for polish movie,Yes,No,No,No,1,0,0,0,1,1- , ,Hebrew,hebrew,spanish,pt,polish,pt,polish,None,2,English,superdude1,235.236.124.347,Active,he for active,es for active,pt for active,pl for active,/images/active.PNG,Yahoo,2007-03-22,2007-03-22 9:18:14,<<jflksajdfsdaf>>,None,Best to paraphrase a description from IMDB.com,None,None,None ) so what the hell is wrong? - thanks Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/ Share on other sites More sharing options...
benjaminbeazy Posted March 22, 2007 Share Posted March 22, 2007 have you tried puttying the insert query in double quotes? then you dont need to escape it to parse the values make sure to put mysql_error() to see any syntax errors or otherwise $query1 = "INSERT INTO `mainfilelist` ( `FIELD` ) VALUES ( '$VALUE')"; $runquery1 = mysql_query( $query1 ) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213049 Share on other sites More sharing options...
dsaba Posted March 22, 2007 Author Share Posted March 22, 2007 damn its always the simple things! yeah i forgot about the mysql_error function, that really helps it tells me i have a syntax error somewhere thanks Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213053 Share on other sites More sharing options...
benjaminbeazy Posted March 22, 2007 Share Posted March 22, 2007 yup just a side note, i myself always have problems trying to escape single quoted queries and use the schema i showed you Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213055 Share on other sites More sharing options...
dsaba Posted March 22, 2007 Author Share Posted March 22, 2007 *edit Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213059 Share on other sites More sharing options...
ShibSta Posted March 22, 2007 Share Posted March 22, 2007 I don't know if it matters but I'd change the way you're placing the variables and place it into a double quote... $query1 = "INSERT INTO `mainfilelist` ( `filename_en`, `filegeneraltype_en`, `filegeneraltype_he`, `filegeneraltype_es`, `filegeneraltype_pt`, `filegeneraltype_pl`, `filespecifictype_en`, `filespecifictype_he`, `filespecifictype_es`, `filespecifictype_pt`, `filespecifictype_pl`, `fileifwalla`, `fileifyahoo`, `fileifgmail`, `fileiflycos`, `filenumwalla`, `filenumyahoo`, `filenumgmail`, `filenumlycos`, `filetotalmirrors`, `filewhatmirrors`, `filelanguage_en`, `filelanguage_he`, `filelanguage_es`, `filelanguage_pt`, `filelanguage_pl`, `fileifpassword_en`, `fileifpassword_he`, `fileifpassword_es`, `fileifpassword_pt`, `fileifpassword_pl`, `filepassword`, `filetemplateid`, `filesubmitlang`, `fileusername`, `fileuserip`, `filestatus_en`, `filestatus_he`, `filestatus_es`, `filestatus_pt`, `filestatus_pl`, `filestatusimage`, `filesentfrom`, `filedateadded`, `filedatetime`, `filehash1`, `filehash2`, `filedescription_en`, `fileimageurl1`, `fileimageurl2`, `fileimageurl3` ) VALUES ( '{$filename}', '{$transgeneraltype_en}', '{$transgeneraltype_he}', '{$transgeneraltype_es}', '{$transgeneraltype_pt}', '{$transgeneraltype_pl}', '{$transspecifictype_en}', '{$transspecifictype_he}', '{$transspecifictype_es}', '{$transspecifictype_pt}', '{$transspecifictype_pl}', '{$fileifwalla}', '{$fileifyahoo}', '{$fileifgmail}', '{$fileiflycos}', '{$filenumwalla}', '{$filenumyahoo}', '{$filenumgmail}', '{$filenumlycos}', '{$filetotalmirrors}', '{$filewhatmirrors}', '{$transfilelanguage_en}', '{$transfilelanguage_he}', '{$transfilelanguage_es}', '{$transfilelanguage_pt}', '{$transfilelanguage_pl}', '{$transifpassword_pt}', '{$transifpassword_pl}', '{$filepassword}', '{$filetemplateid}', '{$userlanguage_en}', '{$fileusername}', '{$fileuserip}', '{$transfilestatus_en}', '{$transfilestatus_he}', '{$transfilestatus_es}', '{$transfilestatus_pt}', '{$transfilestatus_pl}', '{$filestatusimage}', '{$filesentfrom}', '{$date}', '{$datetime}', '{$filehash1}', '{$filehash2}', '{$filedescription}', '{$fileimageurl1}', '{$fileimageurl2}', '{$fileimageurl3}' )"; Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213060 Share on other sites More sharing options...
dsaba Posted March 22, 2007 Author Share Posted March 22, 2007 i foudn the problem i screwed in the syntax in my efforts to echo the variables in the query by "dotting" so i fixed that, ran the mysql_error function and it tells me this: Column count doesn't match value count at row 1 so i saw where i accidently deleted too many lines and there are not enough values for columns -thanks for the help php freaks! Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213063 Share on other sites More sharing options...
ShibSta Posted March 22, 2007 Share Posted March 22, 2007 *edit After counting them, you have 51 table fields to insert values into but only 48 values listed. Thats whats causing the error. Link to comment https://forums.phpfreaks.com/topic/43890-solved-why-does-this-mysql-query-not-return-true-or-1-take-a-look-simple-code/#findComment-213067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.