Cooper94 Posted August 31, 2009 Share Posted August 31, 2009 <?php if(isset($_POST['add_photo'])){ $url = $_POST['url']; $sql=mysql_query("INSERT INTO photo (url)VALUES('$url')"); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); } ?> I get this error Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/purifi/public_html/nyhalofans.com/add_photo.php on line 42 Error: Thank you in advance for helping me! Quote Link to comment https://forums.phpfreaks.com/topic/172547-mysql-error/ Share on other sites More sharing options...
ignace Posted August 31, 2009 Share Posted August 31, 2009 $sql="INSERT INTO photo (url)VALUES('$url')"; if (!mysql_query($sql,$con)) Quote Link to comment https://forums.phpfreaks.com/topic/172547-mysql-error/#findComment-909569 Share on other sites More sharing options...
Cooper94 Posted August 31, 2009 Author Share Posted August 31, 2009 That did not fix it, still gives me that error. Thank You Quote Link to comment https://forums.phpfreaks.com/topic/172547-mysql-error/#findComment-909572 Share on other sites More sharing options...
Cooper94 Posted August 31, 2009 Author Share Posted August 31, 2009 I have fixed the error before but now I am getting this: 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 'by) VALUES('test','edited','tesss','test')' at line 1 With this code: <?php if (isset($_POST['add_photo'])){ $url = $_POST['url']; $section = $_POST['section']; $title = $_POST['title']; $sql="INSERT INTO photo (url, section, title, by) VALUES('$url','$section','$title','test')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/172547-mysql-error/#findComment-909591 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.