[exec-php] How to use databse queries with exec-php?
-
Hi, i’m trying to execute the following sql query from the same database that WP is. but to a seperate table not related to WP. I tried everything i can but i’m unable to execute the code.
$sqlGG = “SELECT stdName,stdNo,sitting,sdMK,isMK,cntMK,(sdMK+isMK+cntMK) AS totMK, ROUND(((sdMK+isMK+cntMK)/3),2) AS avgMK FROM bcs”; $cxnGG = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die(”Couldn’t Connect to DB”); $dbGG = mysql_select_db(DB_NAME,$cxnGG) or die(”Eroor : “.mysql_error($dbGG)); $resultGG = mysql_query($sqlGG) or die(”Query failed: “.mysql_error()); while($rowGG = mysql_fetch_assoc($resultGG)) { echo “ <tr> <td class=\"row1\">".$rowGG['stdName']."</td> <td>".$rowGG['stdNo']."</td> <td>".$rowGG['sitting']."</td> <td>".$rowGG['sdMK']."</td> <td>".$rowGG['isMK']."</td> <td>".$rowGG['cntMK']."</td> <td>".$rowGG['totMK']."</td> <td>".$rowGG['avgMK']."</td> </tr>"; } mysql_close($cxnGG); ?>
if i remove the $sqlGG a page gets displayed with errors. but if the sql is there then an internal error/misconfiguration error 500 page is being displayed. pls tell me what ami doing wrong here. i urgently need the page setup on blog.
Thanks.
note: i have removed the “
” from the sql command.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[exec-php] How to use databse queries with exec-php?’ is closed to new replies.