dsaba Posted February 27, 2007 Share Posted February 27, 2007 ok i'm in desperation been parsing this one simple script for hours all day today this is one of those things i never want to do because i don't take your help for granted and I don't want to ask you to do everything for me, but I am frustrated my script is supposed to add things to a database and then display a success statement when its added correctly, if its not its supposed to say: "There was a problem with the file you uploaded or the data you submitted. Try resubmitting again, if problem persists post an error ticket here " and then the mysql error well it only says that, and NO mysql error, so i dont know whats wrong i also want to know if there is a better way to troubleshoot and check if each query went through succesfully one by one thank u here is my code: <?php //-------THIS IS THE VIDEOFORMINSERT_EN VERSION------------------------- //-------------------------------------------------------------------- //already added include file to connect to database //getting info from html form, making them into variables //for ease of use //can use a number of different calling syntax like POST or REQUEST //video information $svideoname = $_POST['svideoname']; $s4transvideospecifictype = $_POST['svideospecifictype']; $s4transvideogeneraltype = "Videos"; $s4transvideolang = $_POST['svideolanguage']; $s4transvideoifsubtitles = $_POST['svideoifsubtitle']; $s4transvideosubtitlelang = $_POST['svideosubtitlelang']; $svideoimageurl1 = $_POST['svideoimageurl1']; $svideoimageurl2 = $_POST['svideoimageurl2']; $svideoimageurl3 = $_POST['svideoimageurl3']; $svideodescription = $_POST['svideodescription']; //moorhunt information $svideohash1 = $_POST['svideohashcode1']; $svideohash2 = $_POST['svideohashcode2']; $svideoifpassword = $_POST['svideoifpassword']; $svideopassword = $_POST['svideopassword']; $svideosentfrom = $_POST['svideosentfrom']; //what mirrors are used, 1=yes, 0=no $svideoifwalla = $_POST['svideoifwalla']; $svideoifyahoo = $_POST['svideoifyahoo']; $svideoifgmail = $_POST['svideoifgmail']; $svideoiflycos = $_POST['svideoiflycos']; $wallamirror = <<<EOT <img src="/images/logowalla.PNG"> EOT; $yahoomirror = <<<EOT <img src="/images/logoyahoo.PNG"> EOT; $gmailmirror = <<<EOT <img src="/images/logogmail.PNG"> EOT; $lycosmirror = <<<EOT <img src="/images/logolycos.PNG"> EOT; //number of mirrors per each email used $svideonumwalla = $_POST['svideonumwalla']; $svideonumyahoo = $_POST['svideonumyahoo']; $svideonumgmail = $_POST['svideonumgmail']; $svideonumlycos = $_POST['svideonumlycos']; //total number of mirrors $svideototalmirrors = $_POST['svideototalmirrors']; $svideowhatmirrors = "$svideonumwalla- $wallamirror, $svideonumyahoo- $yahoomirror, $svideonumgmail- $gmailmirror, $svideonumlycos- $lycosmirror"; //user or submitter information, possible to use this to click on user name and have stats for user and link to website $svideosubmitter = $_POST['svideosubmitter']; $svideosubmitteremail = $_POST['svideosubmitteremail']; $svideosubmitterwebsite = $_POST['svideosubmitterwebsite']; $svideodateadded = date("Y-m-d"); $svideodatetime = date("Y-m-d g:i:s"); $svideosubmitterip = $_SERVER['REMOTE_ADDR']; $svideosubmitlang = "en"; $svideotemplateid = "1"; $fileactive = <<<EOT <img src="/images/fileactive.PNG"> EOT; //variables for translations //defining $transgeneraltype, $transspecifictype, $transfilelanguage, $transifsubtitles, $transsubtitlelang, $transifpassword switch ($s4transvideogeneraltype) { case "Videos" : $transgeneraltype_en = "Videos"; $transgeneraltype_he = "Sratim"; $transgeneraltype_es = "Peliculas"; $transgeneraltype_pt = "pt word for video"; $transgeneraltype_pl = "pl word for video"; break; default : echo "unable to determine and translate filegeneraltype"; break; } switch ($s4transvideospecifictype) { case "Anime" : $transspecifictype_en = "Anime"; $transspecifictype_he = "hebrew for anime"; $transspecifictype_es = "spanish for anime"; $transspecifictype_pt = "pt for anime"; $transspecifictype_pl = "polish for anime"; break; case "Divx Movies" : $transspecifictype_en = "Divx Movies"; $transspecifictype_he = "he for divx movie"; $transspecifictype_es = "es for divx movie"; $transspecifictype_pt = "pt for divx movie"; $transspecifictype_pl = "pl for divx movie"; break; case "PSP Movies" : $transspecifictype_en = "PSP Movies"; $transspecifictype_he = "he for psp movie"; $transspecifictype_es = "es for psp movie"; $transspecifictype_pt = "pt for psp movie"; $transspecifictype_pl = "pl for polish movie"; break; case "Ipod Movies" : $transspecifictype_en = "Ipod Movies"; $transspecifictype_he = "hebrew translation"; $transspecifictype_es = "spanish translation"; $transspecifictype_pt = "pt translation"; $transspecifictype_pl = "polish translation"; break; case "Full DVDs" : $transspecifictype_en = "Full DVDs"; $transspecifictype_he = "hebrew translation"; $transspecifictype_es = "spanish translation"; $transspecifictype_pt = "pt translation"; $transspecifictype_pl = "polish translation"; break; case "Other Videos" : $transspecifictype_en = "Other Videos"; $transspecifictype_he = "hebrew translation"; $transspecifictype_es = "spanish translation"; $transspecifictype_pt = "pt translation"; $transspecifictype_pl = "polish translation"; break; default : echo "unable to translate filespecifictype"; break; } switch ($s4transvideolang) { case "English" : $transfilelanguage_en = "English"; $transfilelanguage_he = "hebrew"; $transfilelanguage_es = "spanish"; $transfilelanguage_pt = "pt"; $transfilelanguage_pl = "polish"; break; case "Hebrew" : $transfilelanguage_en = "Hebrew"; $transfilelanguage_he = "hebrew"; $transfilelanguage_es = "spanish"; $transfilelanguage_pt = "pt"; $transfilelanguage_pl = "polish"; break; case "Spanish" : $transfilelanguage_en = "spanish"; $transfilelanguage_he = "hebrew"; $transfilelanguage_es = "spanish"; $transfilelanguage_pt = "pt"; $transfilelanguage_pl = "polish"; break; case "Portuguese" : $transfilelanguage_en = "portuguese"; $transfilelanguage_he = "hebrew"; $transfilelanguage_es = "spanish"; $transfilelanguage_pt = "pt"; $transfilelanguage_pl = "polish"; break; case "Polish" : $transfilelanguage_en = "polish"; $transfilelanguage_he = "hebrew"; $transfilelanguage_es = "spanish"; $transfilelanguage_pt = "pt"; $transfilelanguage_pl = "polish"; break; default : echo "unable to translate filelanguage"; break; } switch ($s4transvideoifsubtitles) { case "Yes" : $transifsubtitles_en = "Yes"; $transifsubtitles_he = "Ken"; $transifsubtitles_es = "spanish"; $transifsubtitles_pt = "pt"; $transifsubtitles_pl = "polish"; break; case "No" : $transifsubtitles_en = "No"; $transifsubtitles_he = "Lo"; $transfilelanguage_es = "spanish"; $transifsubtitles_pt = "pt"; $transifsubtitles_pl = "polish"; break; default : echo "unable to translate ifsubtitles"; break; } switch ($s4transvideosubtitlelang) { case "English" : $transsubtitlelanguage_en = "English"; $transsubtitlelanguage_he = "hebrew"; $transsubtitlelanguage_es = "spanish"; $transsubtitlelanguage_pt = "pt"; $transsubtitlelanguage_pl = "polish"; break; case "Hebrew" : $transsubtitlelanguage_en = "English"; $transsubtitlelanguage_he = "hebrew"; $transsubtitlelanguage_es = "spanish"; $transsubtitlelanguage_pt = "pt"; $transsubtitlelanguage_pl = "polish"; break; case "Spanish" : $transsubtitlelanguage_en = "English"; $transsubtitlelanguage_he = "hebrew"; $transsubtitlelanguage_es = "spanish"; $transsubtitlelanguage_pt = "pt"; $transsubtitlelanguage_pl = "polish"; break; case "Portuguese" : $transsubtitlelanguage_en = "English"; $transsubtitlelanguage_he = "hebrew"; $transsubtitlelanguage_es = "spanish"; $transsubtitlelanguage_pt = "pt"; $transsubtitlelanguage_pl = "polish"; break; case "Polish" : $transsubtitlelanguage_en = "English"; $transsubtitlelanguage_he = "hebrew"; $transsubtitlelanguage_es = "spanish"; $transsubtitlelanguage_pt = "pt"; $transsubtitlelanguage_pl = "polish"; break; default : echo "unable to translate subtitlelanguage"; break; } //definetly in the future make an include command for this $connect = mysql_connect("notdisclosed", "notdisclosed", "notdisclosed") or die ("Hey loser, check your server connection."); mysql_select_db("mydatabase"); //if $svideofilename is not defined in db then create a new record $result = mysql_query("SELECT filename FROM mainfilelist WHERE filename='$svideoname'"); $row = mysql_fetch_assoc($result); if ($row['filename'] == $svideoname) { echo 'This file has already been uploaded, try uploading another one<br>'; } else { $query1 = "INSERT INTO `mainfilelist` ( `filename`, `filegeneraltype_en`, `filegeneraltype_he`, `filegeneraltype_es`, `filegeneraltype_pt`, `filegeneraltype_pl`, `filespecifictype_en`, `filespecifictype_he`, `filespecifictype_es`, `filespecifictype_pt`, `filespecifictype_pl`, `filewallamirror_`, `fileyahoomirror`, `filegmailmirror`, `filelycosmirror`, `filelanguage_en`, `filelanguage_he`, `filelanguage_es`, `filelanguage_pt`, `filelanguage_pl`, `fileifsubtitles_en`, `fileifsubtitles_he`, `fileifsubtitles_es`, `fileifsubtitles_pt`, `fileifsubtitles_pl`, `filesubtitlelang_en`, `filesubtitlelang_he`, `filesubtitlelang_es`, `filesubtitlelang_pt`, `filesubtitlelang_pl`, `fileifpassword`, `filesubmitter`, `filedateadded`, `filetotalmirrors`, `filetemplateid`, `filesubmitlang`, `fileactive` ) VALUES ( '$svideoname','$transgeneraltype_en','$transgeneraltype_he','$transgeneraltype_es','$transgeneraltype_pt','$transgeneraltype_pl','$transspecifictype_en','$transspecifictype_he','$transspecifictype_es','$transspecifictype_pt','$transspecifictype_pl','$svideoifwalla','$svideoifyahoo','$svideoifgmail','$svideoiflycos','$transfilelanguage_en','$transfilelanguage_he','$transfilelanguage_es','$transfilelanguage_pt','$transfilelanguage_pl','$transifsubtitles_en','$transifsubtitles_he','$transifsubtitles_es','$transifsubtitles_pt','$transifsubtitles_pl','$transsubtitlelanguage_en','$transsubtitlelanguage_he','$transsubtitlelanguage_es','$transsubtitlelanguage_pt','$transsubtitlelanguage_pl','$svideoifpassword','$svideosubmitter','$svideodateadded','$svideototalmirrors','$svideotemplateid','$svideosubmitlang','$fileactive' )"; //get newly generated fileid from above process and make into a variable for below insertion $result2 = mysql_query("SELECT fileid FROM mainfilelist WHERE filename='$svideoname'"); $fetchedfileid = mysql_fetch_row($result2); //second part of else statement $query2 = "INSERT INTO `videos` ( `videoname`, `videofileid`, `videogeneraltype_en`, `videogeneraltype_he`, `videogeneraltype_es`, `svideogeneraltype_pt`, `videogeneraltype_pl`, `videospecifictype_en`, `videospecifictype_he`, `videospecifictype_es`, `videospecifictype_pt`, `videospecifictype_pl`, `videosubmitter`, `videosubmitterip`, `videodateadded`, `videoifwalla`, `videoifyahoo`, `videoifgmail`, `videoiflycos`, `videowhatmirrors`, `videototalmirrors`, `videosubmitlang`, `videolanguage_en`, `videolanguage_he`, `videolanguage_es`, `videolanguage_pt`, `videolanguage_pl`, `videoifsubtitles_en`, `videoifsubtitles_he`, `videoifsubtitles_es`, `videoifsubtitles_pt`, `videoifsubtitles_pl`, `videosubtitlelang_en`, `videosubtitlelang_he`, `videosubtitlelang_es`, `videosubtitlelang_pt`, `videosubtitlelang_pl`, `videotemplateid`, `videohash1`, `videohash2`, `videodescription`, `videoimageurl1`, `videoimageurl2`,videoimageurl3 `videonumwalla`, `videonumyahoo`, `videonumgmail`, `videonumlycos`, `videosentfrom`, `videofileactive`, `videoifpassword`, `videopassword` ) VALUES ( '$svideoname', '$fetchedfileid', '$transgeneraltype_en', '$transgeneraltype_he', '$transgeneraltype_es', '$transgeneraltype_pt', '$transgeneraltype_pl', '$transspecifictype_en', '$transspecifictype_he', '$transspecifictype_es', '$transspecifictype_pt', '$transspecifictype_pl', '$svideosubmitter', '$svideosubmitterip', '$svideodateadded', '$svideoifwalla', '$svideoifyahoo', '$svideoifgmail', '$svideoiflycos', '$svideowhatmirrors', '$svideototalmirrors', '$transfilelanguage_en', '$transfilelanguage_he', '$transfilelanguage_es', '$transfilelanguage_pt', '$transfilelanguage_pl', '$transifsubtitles_en', '$transifsubtitles_he', '$transifsubtitles_es', '$transifsubtitles_pt', '$transifsubtitles_pl', '$transsubtitlelanguage_en', '$transsubtitlelanguage_he', '$transsubtitlelanguage_es', '$transsubtitlelanguage_pt', '$transsubtitlelanguage_pl', '$svideotemplateid', '$svideohash1', '$svideohash2', '$svideodescription', '$svideoimageurl1', '$svideoimageurl2', '$svideoimageurl3', '$svideonumwalla', '$svideonumyahoo', '$svideonumgmail', '$svideonumlycos', '$svideosentfrom', '$fileactive', '$svideoifpassword', '$svideopassword' )"; } //make a variable for $userfilecount, learn how to count number of fileids in the mainfilelist table where username=username $userfilecountifnew = 1; $result = mysql_query("SELECT filesubmitter FROM mainfilelist WHERE filesubmitter='$svideosubmitter'"); $userfilecount = mysql_num_rows($result); //now adding or updating users table in database $result = mysql_query("SELECT userip FROM userinfo WHERE username='$svideosubmitter'"); $row = mysql_fetch_assoc($result); if ($row['username'] == $svideosubmitter) { $query3 = "UPDATE `userinfo` SET `userip`='$svideosubmitterip', `userlanguage`='$svideosubmitlang', `useremail`='$videosubmitteremail', `userwebsite`='$svideosubmitterwebsite', `userfilecount`='$userfilecount', 'userlastactive'='$svideodatetime' WHERE `username`='$svideosubmitter'"; } else { $query4 = "INSERT INTO `userinfo` ( `username`, `userip`, `useremail`, `userwebsite`, `userlanguage`, `userfilecount`, `userlastactive` ) VALUES ( '$svideosubmitter','$svideosubmitterip','$svideosubmitteremail','$svideosubmitterwebsite','$svideosubmitterlang','$userfilecountifnew','$svideodatetime' )"; } //make userlink and filelink links, put them into db as userlink and filelink $result = mysql_query("SELECT userid FROM userinfo WHERE username='$svideosubmitter'"); $row = mysql_fetch_assoc($result); $fetcheduserid = " '".$row['userid']."' "; $userlink = <<<EOT <a href="/userinfo.php?id=$fetcheduserid" target="_self">$videosubmitter</a> EOT; $query5 = "UPDATE `userinfo` SET `userlink`='$userlink' WHERE `userid`='$fetcheduserid'"; //other query for filelink $filelink = <<<EOT <a href="/video.php?id=$fetchedfileid" target="_self">$videoname</a> EOT; $query6 = "UPDATE `mainfilelist` SET `filelink`='$filelink' WHERE `fileid`='$fetchedfileid'"; //data is now in the database $results1 = mysql_query( $query1 ); $results2 = mysql_query( $query2 ); $results3 = mysql_query( $query3 ); $results4 = mysql_query( $query4 ); $results5 = mysql_query( $query5 ); $results6 = mysql_query( $query6 ); //success statement based on results if( $results1 && $results2 && $results3 && $results4 && $results5 && $results6 ) { echo( "Thank you, $svideosubmitter<br>You have succesfully submitted a file into the database!<br>With your help the P2MHunT database can become the largest P2M database in the world! click here to view your file $filelink"); } else { die( "There was a problem with the file you uploaded or the data you submitted. <br>Try resubmitting again, if problem persists post an error ticket here $filelink" . mysql_error() ); } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/40282-solved-to-check-for-query-or-mysql-succes/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.