Reputation: 23
This is what I currently have, super basic. Still cant get it working :/
$connection = mysql_connect("localhost","root","")
or die ("Couldn't connect to server");
$db = mysql_select_db("streetRider",$connection)
or die ("Couldn't select database");
$result = mysql_query(sprintf("INSERT INTO video(id, parent_id, video, coverImage,
ts_created, is_void) VALUES('%s','%s','%s', '%s', '%s','%s')", $unique_id, $parent_id,$videoDirectory,$imageDirectory, $ts_created, $is_void));
What am i Missing???? :(
OK Guys so if one of my variables I'm storing is equal to this it works:
$videoDirectory = 'userVideos/'.$unique_id;
When my variable is equal to this, the insert FAILS: $videoDirectory = 'userVideos/'.$unique_id.'.mp4';
Its really puzzling and frustrating, but thats what I figured out.video is datatype varchar(50).
Upvotes: 0
Views: 90
Reputation: 64476
You have assigned the columns with %s
but your query
function does have the sprintf()
call in it? Try this
$result = mysql_query(sprintf("INSERT INTO video(id, parent_id, video, coverImage,
ts_created, is_void)
VALUES('%s','%s','%s', '%s', '%s','%s')",
$unique_id, $parent_id,$videoDirectory,$imageDirectory, $ts_created, $is_void));
Please, don't use
mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
Upvotes: 1
Reputation: 37233
i dont know you are using prepared statment or mysql anyway if you are tagged mysql then try this
$result = mysql_query("INSERT INTO video(id, parent_id, video, coverImage, ts_created, is_void) VALUES ($unique_id, $parent_id,$videoDirectory,$imageDirectory, $ts_created, $is_void ) ")
Upvotes: 0