Forums

MySQl query fails

panky23 25 Feb, 2010
Hi there
I need to display number of cards saved from members.
So I add in my chronoform this:

<?php 

//echo "{card}";
$db2 =& JFactory::getDBO();


$sql="SELECT COUNT(*) AS number FROM #__chronoforms_rolodex WHERE card='{card}' ";
echo $sql;
$db2->setQuery($sql);
$result=$db2->loadObject();

echo "Saved ".$result->number." times<br>";
?>


But query returns empty always.
If I run the same code in test page all OK, inside my Chronoforms I think I can't exec mysql query or... I don't know.
I'm lost, please help.
GreyHead 25 Feb, 2010
Hi panky23,

Where are you using this code?

The MySQL looks OK but you can only use {card} in a few places - not in the Form HTML.

If this is the Form HTML where do you expect to get the value of {card} from?

Bob
panky23 25 Feb, 2010
Thanks by replying🙂
I don't know how explain you exactly where I use it.
From Components / Chrono Connectivity / Connections Management / Card (one of my connections links):
So in BODY my full code is:

<div style="float:left; margin:6px"><a onmouseover="return this.onclick()" onclick="return hs.expand(this,{align: 'center', allowSizeReduction: true, autoplay: false, captionId: '{business_name}', hsjcaption: '<b>Business Name:</b>{business_name}<br/><b>Telephone:</b>{number}<br/><b>Fax:</b>{fax}<br/><b>Website:</b>{website}<br/><b>{category}</b>'})" class="highslide" id="imageloader_anchor_0" href="components/com_chronocontact/uploads/card/{card}" title="{business_name}"><img src="components/com_chronocontact/uploads/card/{card}" width="190" height="110" border=0></a><br/>
{reg}
 <form name="ChronoContact_rolodex" id="ChronoContact_rolodex" method="post" action="http://www.onemillionbizcards.com/new/index.php?option=com_chronocontact&task=send&chronoformname=rolodex" >
		
				<input value="{card}" id="hidden_1" name="card" type="hidden" />

<div class="form_item">
  <div class="form_element cf_button">
    <input type="image" name="submit" src="/new/images/icon-rolodex.gif" />

  </div>
  <div class="cfclear"> </div>
</div>
		
                        	        </form>
{/reg}
{pub}
<center><font site="1"><?php 

$db2 =& JFactory::getDBO();

$sql="SELECT card, COUNT(*) AS number FROM #__chronoforms_rolodex WHERE card='{card}'";
$db2->setQuery($sql);
$result=$db2->loadObject();

echo $result->card." Saved ".$result->number." times<br>";

?>
</font></center><br>
<a href="index.php?option=com_comprofiler&task=login&Itemid=35"><img src="/new/images/icon-rolodex2.gif" border=0 width="180"></a>
{/pub}
</div>


In bold my php code where I try to add mysql query to display how times were saved every card.
People is telling me it's because my version is free version but... I thought free version had not limitations.
Waiting your words, thanks again.
GreyHead 25 Feb, 2010
Hi panky23,

If I understand correctly this is in the ChronoConenctivity 'Body' box.

I don't think that you can use MySQL there (the body section is executed inside a MySQL loop and the two interfere.

Instead put the MySQL into the Header box and use the appropriate line(s) of the results in the body section.

You may also find it easier to use the Add Form Tag option in ChronoConnectivity to create a single forem on the page rather than having many forms with the same name and id.

Bob
panky23 25 Feb, 2010
:oops: I see
So I have a problem because I think I can't get card value from header, at least I don't see how.
Thanks a lot.
GreyHead 25 Feb, 2010
Hi panky23,

So, as I asked earlier, where do you get the value of {card} from? I assume that it's from the MySQL / WHERE clause of the ChronoConnection and the Connection is not based on the same table as your query in the body?

If so then at the moment CC does not support compound queries (with JOINed tables), I do have a test version developed for a client that will do that but it's nto robust enough to publish.

You might be able to set up a temporary MySQL table that joins both of the other tables and query that? I forget the exact terminology but someone made a post here suggesting it.

Bob
panky23 25 Feb, 2010
Thanks for all GreyHead, you are very nice.
I wait anxious that version is ready to publish 😛
For now (don't laugh please) I found a dirty solution: I insert there this:

{pub}
<center><iframe name="I1" width="190" height="31" src="saved_cards.php?card={card}" scrolling="no" border="0" frameborder="0">
Update your Browser</iframe></center><br>
<a href="index.php?option=com_comprofiler&task=login&Itemid=35"><img src="/new/images/icon-rolodex2.gif" border=0 width="180"></a>


{/pub}


So I can display how time were saved every card.
I know it's ugly but... step by step 🙂
Thanks again.
This topic is locked and no more replies can be posted.