mdarling Posted March 23, 2010 Share Posted March 23, 2010 ok so i cant get the create veiw to work .... it will work in phpmyadmin and with dbforge but not in the site... here is the code my server version is 5.1.36 the errors i get are: either the table comply is not there or if i exclude the 2nd select statement i get no database selected but i can run other query's just fine!... and all permissions are set for the user. $sql1=mysql_query(" CREATE VIEW comply AS SELECT quiz_compliance.grade, quiz.title as 'quiz', course.title as 'course', quiz_compliance.finish, user.first, user.last, user.id FROM $dbname.course_enrollments INNER JOIN $dbname.course ON course_enrollments.course_id = course.id INNER JOIN $dbname.user ON course_enrollments.user_id = user.id INNER JOIN $dbname.quiz_compliance INNER JOIN $dbname.quiz ON quiz.course_id = course.id AND quiz_compliance.quiz_id = quiz.id WHERE quiz_compliance.user_id = user.id AND course.id = '7' "); $sql4=mysql_query(" SELECT user.id, user.`first`, user.`last` FROM emscloud.user LEFT OUTER JOIN emscloud.comply ON user.id = emscloud.comply.id WHERE emscloud.comply.id IS NULL"); echo "\n\n"; echo "User ID,Last,First,\n\n"; if ($sql1){ while($s=mysql_fetch_array($sql4)){ $user_id = $s["id"]; $Last_name = $s["last"]; $first_name = $s["first"]; echo $user_id.",".$Last_name.",".$first_name; echo "\n"; } }else{ print mysql_error();} Quote Link to comment https://forums.phpfreaks.com/topic/196249-php-mysql-create-view/ Share on other sites More sharing options...
zeodragonzord Posted March 28, 2010 Share Posted March 28, 2010 Try selecting the database first and see if that helps. USE databasename; When you first connect to your database, you should select the database name as well. Make sure it does that already; if so you don't need to use the above code. Also, check to make sure the View is not already there, if you're testing it, you may have created this table already. Quote Link to comment https://forums.phpfreaks.com/topic/196249-php-mysql-create-view/#findComment-1033129 Share on other sites More sharing options...
Mchl Posted March 28, 2010 Share Posted March 28, 2010 mysql_select_db Quote Link to comment https://forums.phpfreaks.com/topic/196249-php-mysql-create-view/#findComment-1033141 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.