Hello all!
I recently started a project with the members module of Couch cms, everything is going perfect except one thing.
When a user logins I want to use his member_name as a value inside an query to filter the data from a table of an external database. The problem is that whatever I tried it always seems to be wrong.
Here's the code:
Now if I echo the value of $cid it returns 123456789.
And if I manually code
I get the expected result.
But if I code
it doesnt return the proper result.
Here's the output of var_dump($cid) : string(26) "123456789"
Any help would be great!I am stuck for about a week!!
I recently started a project with the members module of Couch cms, everything is going perfect except one thing.
When a user logins I want to use his member_name as a value inside an query to filter the data from a table of an external database. The problem is that whatever I tried it always seems to be wrong.
Here's the code:
- Code: Select all
<cms:form masterpage=k_member_template mode='edit' page_id=k_member_id enctype="multipart/form-data" method='post' anchor='0' > <cms:if k_success > <cms:db_persist_form /> <cms:set_flash name='success_msg' value='1' /> <cms:redirect k_page_link /> </cms:if> <cms:if k_error > <font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font> </cms:if> <table class="tg" style="width:100%"> <tr> <th class="tg-yw41" style="text-align:left;border-top:none"><strong>ΟΝΟΜΑ ΜΕΛΟΥΣ:</strong></th> <th class="tg-yw4l" style="border-top:none"><cms:pages masterpage='members/index.php' page_name=k_member_name> <cms:show member_firstname /></cms:pages></span></th> </tr> <tr> <td class="tg-yw4l"> <strong>ΕΠΩΝΥΜΟ ΜΕΛΟΥΣ:</strong></td> <td class="tg-yw4l"><cms:pages masterpage='members/index.php' page_name=k_member_name> <cms:show member_lastname /></cms:pages></td> </tr> <tr> <td class="tg-yw4l"> <strong>ΑΡΙΘΜΟΣ ΚΑΡΤΑΣ:</strong></td> <td class="tg-yw4l"><cms:pages masterpage='members/index.php' page_name=k_member_name> <cms:show k_member_name /><br> </cms:pages> </td> </tr> <tr> <td class="tg-yw4l"> <strong>ΑΡΙΘΜΟΣ ΠΟΝΤΩΝ:</strong></td> <td class="tg-yw4l"> <?php $servername = "***********"; $username = "**********"; $password = "********"; $dbname = "********"; $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $cid='<cms:show k_member_name />'; $sql = "SELECT points FROM CUSTOMERS WHERE CardId =". $cid. ""; echo $sql; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo $row["points"]; } } else { echo "ERROR"; } $conn->close(); ?></td> </tr> </table> <!-- <cms:if k_member_logged_in > <cms:show k_member_name /> </cms:if> --> </cms:form>
Now if I echo the value of $cid it returns 123456789.
And if I manually code
- Code: Select all
$sql = "SELECT points FROM CUSTOMERS WHERE CardId =123456789";
I get the expected result.
But if I code
- Code: Select all
$sql = "SELECT points FROM CUSTOMERS WHERE CardId =". $cid. "";
it doesnt return the proper result.
Here's the output of var_dump($cid) : string(26) "123456789"
Any help would be great!I am stuck for about a week!!