lauram340 Posted January 22, 2009 Share Posted January 22, 2009 I have got an error but i don't understand what it means My error says Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Users\Laura\Desktop\UPDATE\UPDATE\Update\www\police\content\crud_single_table\confirm_insert.php on line 3 and my code is this $sql = "SELECT COUNT(*) FROM Workshift WHERE NAME ='$a_name_variable'"; $result3= mysql_query($sql, $db); $count= mysql_result($result3,0,"COUNT(*)"); if ($count >= 2) { echo 'You are already working the max, 2 shifts.'; } I can see its the mysql_query and mysql_result but how do i overcome this error and why is it saying its there? Link to comment https://forums.phpfreaks.com/topic/141916-mysql-link-error/ Share on other sites More sharing options...
Mchl Posted January 22, 2009 Share Posted January 22, 2009 Did you connect to database and stored a connection in $db variable? Link to comment https://forums.phpfreaks.com/topic/141916-mysql-link-error/#findComment-743053 Share on other sites More sharing options...
gnawz Posted January 22, 2009 Share Posted January 22, 2009 You have to show more code. this error is sometimes due to code placed wrongly, logically or something is missing Link to comment https://forums.phpfreaks.com/topic/141916-mysql-link-error/#findComment-743054 Share on other sites More sharing options...
lauram340 Posted January 22, 2009 Author Share Posted January 22, 2009 This is in a file called confirm_insert and the database connection is on the index page elsewhere. This is some more code that i was given to work on but don't what it means <?php $sql = "SELECT COUNT(*) FROM Workshift WHERE NAME ='$a_name_variable'"; $result3= mysql_query($sql, $db); $count= mysql_result($result3,0,"COUNT(*)"); if ($count >= 2) { echo 'You are already working the max, 2 shifts.'; } $flag_insert = ''; if (isset($_REQUEST['flag_insert'])) { $flag_insert = $_REQUEST['flag_insert']; } if ($flag_insert == 'OK') { $query_insert = "Insert into ".$table." ("; $flag_position_in_query = 0; for ($i = 0; $i < $columns; $i++) { if (!(strstr(mysql_field_flags($result,$i),'primary_key')) and !(strstr(mysql_field_flags($result,$i),'timestamp'))) { if ($flag_position_in_query > 0) { $query_insert = $query_insert.",".mysql_field_name($result,$i); } else { $query_insert = $query_insert.mysql_field_name($result,$i); $flag_position_in_query++; } } } Link to comment https://forums.phpfreaks.com/topic/141916-mysql-link-error/#findComment-743065 Share on other sites More sharing options...
lauram340 Posted January 22, 2009 Author Share Posted January 22, 2009 Ok, i got it to ignore the errors but its still inserting into the database, if there anyway i can stop this? Link to comment https://forums.phpfreaks.com/topic/141916-mysql-link-error/#findComment-743071 Share on other sites More sharing options...
Mchl Posted January 22, 2009 Share Posted January 22, 2009 This is in a file called confirm_insert and the database connection is on the index page elsewhere. The database connection has to be available within this script. Are you including it into index page? Link to comment https://forums.phpfreaks.com/topic/141916-mysql-link-error/#findComment-743102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.