ldb358 Posted June 4, 2009 Share Posted June 4, 2009 this is part of my php script that is responcable for uploading the users files up to my server and stores the information about the file //assume that all the variables are set <? $check = mysql_query ("SELECT * FROM '$artistFill' LIMIT 0,1"); if($check){ mysql_query("INSERT INTO '$artistFill' (id, name, sType, fSize, artist) VALUES('NULL', '$nameFill', 'photo', '$sizeFill', '$artistFill');") or die(mysql_error()); }else{ //if table doesnt exsist mysql_query("CREATE TABLE '$artistFill' (id INT NOT NULL, name VARCHAR( 30 ) NOT NULL ,fType VARCHAR( 30 ) NOT NULL ,fSize INT NOT NULL ,artist VARCHAR( 30 ) NOT NULL ,fDesc TEXT NOT NULL ,rating INT NOT NULL ,PRIMARY KEY (id))") or die("1"); mysql_query("INSERT INTO '$artistFill' (id, name, sType, fSize, artist) VALUES('NULL', '$nameFill', 'photo', '$sizeFill', '$artist');") or die("2"); echo "added"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/ Share on other sites More sharing options...
ldb358 Posted June 4, 2009 Author Share Posted June 4, 2009 i guess i forgot to mention that both of the query's generate a mysql error that look like "check your mysql version for syntax error .. then read some of the query the function .. in line 1" Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/#findComment-849634 Share on other sites More sharing options...
ldb358 Posted June 4, 2009 Author Share Posted June 4, 2009 the best way to test this is to go to the site http://lbflash.summerhost.info/test username: Lane Password: enter1 then upload a "file" has to be an image and you should see the error if you see a 1 or a 2 that means a query error Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/#findComment-849639 Share on other sites More sharing options...
ldougherty Posted June 5, 2009 Share Posted June 5, 2009 I tried, got a 1 which tells us the query failed.. mysql_query("CREATE TABLE '$artistFill' (id INT NOT NULL, name VARCHAR( 30 ) NOT NULL ,fType VARCHAR( 30 ) NOT NULL ,fSize INT NOT NULL ,artist VARCHAR( 30 ) NOT NULL ,fDesc TEXT NOT NULL ,rating INT NOT NULL ,PRIMARY KEY (id))") or die("1"); Have you tried running this query manually via the mySQL prompt or through phpmyadmin changing the variables to the actual values? Instead of using die("1"); use die(mysql_error()); as this will output the actual error. Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/#findComment-849649 Share on other sites More sharing options...
ldb358 Posted June 5, 2009 Author Share Posted June 5, 2009 it has been fixed so that the mysql_error is shown and yes when run manually it does work Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/#findComment-849664 Share on other sites More sharing options...
ldb358 Posted June 5, 2009 Author Share Posted June 5, 2009 added this if($check){ mysql_query("INSERT INTO ".$artistFill." (id, name, fType, fSize, artist) VALUES(NULL, ".$nameFill.", ".photo.", ".$sizeFill.", ".$artistFill.");") or die(mysql_error()); }else{ //if table doesnt exsist mysql_query("CREATE TABLE ".$artistFill."(id INT NOT NULL, name VARCHAR( 30 ) NOT NULL ,fType VARCHAR( 30 ) NOT NULL ,fSize INT NOT NULL ,artist VARCHAR( 30 ) NOT NULL ,fDesc TEXT NOT NULL ,rating INT NOT NULL ,PRIMARY KEY (id))") or die(mysql_error()); mysql_query("INSERT INTO ".$artistFill." (id, name, sType, fSize, artist) VALUES (NULL, ".$nameFill.", photo, ".$sizeFill.", ".$artist.");") or die(mysql_error()); echo "added"; } now its saying there is an error with the files im trying to up load "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 'of image.jpg, photo, 56372, lane)' at line 1" Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/#findComment-849668 Share on other sites More sharing options...
Ken2k7 Posted June 5, 2009 Share Posted June 5, 2009 Your SQL makes no sense. You create the table indicating that the id field can't be null and you put in null for id in your INSERT. :-\ For int, don't you have to specify a size? Lastly, keep the SQL you had in your first post, but remove the single quotes around $artistFill. Quote Link to comment https://forums.phpfreaks.com/topic/160989-should-be-simple-mysql-query/#findComment-849745 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.