mysql_connect("x.x.x.x"," xxxxxx ","xxxxxxxxx"); $query = "INSERT INTO users (video_url) VALUES ('$path') WHERE username = 'test';" mysql_query($query) or trigger_error("FATAL ERROR: " . mysql_error(), E_USER_ERROR); mysql_close(); Code (markup): I get an error on the last line that says: Parse error: parse error, unexpected T_STRING in videoUpload.php on line 31 Is my SQL statement incorrect?
You are missing a semi-colon after the following line, actually you included it in the SQL query: $query = "INSERT INTO users (video_url) VALUES ('$path') WHERE username = test;" Code (markup):
Hi, below are the errors that i see $query = "INSERT INTO users (video_url) VALUES ('$path') WHERE username = test;" enclose test in quotes ' ' remove the semi-colon ( at the end of test
Well I fixed that error by writing it: $query = "INSERT INTO users (video_url) VALUES ('$path') WHERE username = 'test'"; mysql_query($query) or trigger_error("FATAL ERROR: " . mysql_error(), E_USER_ERROR); But now it's giving me this error: FATAL ERROR: 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 'WHERE username = 'test'' at line 1 in videoUpload.php on line 33
darn, why i didnt i see it INSERT operations dont need a WHERE statement, please remove it $query = "INSERT INTO users (video_url) VALUES ('$path')";
my database has 4 columns user_id, username, password, video_url Now at first the video_url field is blank.. thats why I am using a WHERE... so when the user uploads a video to the server it enters the URL path in that field... if i didnt use WHERE it would just insert the statement anywhere and wouldnt be tagged to a specific user. Am I trying to accomplish this the incorrect way?
yep, you should probably insert the path along with the username or any other informations that your need to include with the video Ex: $query = "INSERT INTO users (user_id, username, video_url) VALUES ($user_id, '$username','$path')"; the $user_id, $username and so forth represents the data that you want to include
Actually I solved my problem by changing my query to: $query = "UPDATE users SET video_url = '$path' WHERE username = 'test'"; Code (markup):
I am trying to insert but my syntax was wrong and I didn't want to monkey around with it.. So UPDATE did the same thing, actually even better because it will append the field if the user ever decides to change their video.