Jump to content

File exists Issues

Recommended Posts

Hey can any one explain why this if statement wont work


$name = "bellgrove_slide_show.mp4"


$temp_video = "Videos/" . $name; echo "temp_video name: " .$temp_video. "<br/>"; if (file_exists($temp_video)) //bellgrove_slide_show.mp4{ echo "The File named: " .$name . " already exists. <br>";}


Yet this version of the statement will work


if (file_exists("Videos/bellgrove_slide_show.mp4")) //bellgrove_slide_show.mp4{ echo "The File named: " .$name . " already exists. <br>";}

Link to post
Share on other sites

Thanks Don E,

but that is not the issue that was included as a test data. the name is equal to $_FILES['video']['name'];(which is bellgrove_slide_show.mp4)


The issue comes from the IF statement itself the first IF statement does not seem to work and kills the page during loading where as the second of the two IF statements will work..the only difference is the file_exist() the first is variable called $temp_vid which is equal to "Videos/bellgrove_slide_show.mp4" and the second is hard coded in to the file_exist() as "Videos/bellgrove_slide_show.mp4"


So by my understanding both IF statements should work however this is not the case as the first IF statement will not work

Edited by BigShieldsy
Link to post
Share on other sites

Hey don thanks mate that little bit of code has helped to see what has been happening and its displaying these errorsWarning: mysql_query() expects parameter 1 to be string, resource given in /home/bellg980/public_html/MembersArea/Highlights/upload_highlight.php on line 53Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/bellg980/public_html/MembersArea/Highlights/upload_highlight.php on line 54


Are these warning alright due to the database table being empty on the first run??


Link to post
Share on other sites

No, it means you aren't using the mysql_query function correctly. It says that it expects a string to be passed, and you are passing a resource. You should really avoid using the mysql functions and instead should use either mysqli or PDO though.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...