Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

problem cb code

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
7 years 3 weeks ago - 7 years 3 weeks ago #299713 by krileon
Replied by krileon on topic problem cb code
As I've already explained you can not use an echo in it. You have to use a return. If it's a loop then change your code to something like the below.

FROM:
Code:
for ( $i = 1; $i <= 7; $i++ ) { echo 'loop' . $i; }
TO:
Code:
$return = null; for ( $i = 1; $i <= 7; $i++ ) { $return .= 'loop' . $i; } return $return;

If you're trying to include a PHP file then do a return on the include and put your return inside your PHP file. Example as follows.

Code:
return include( FILE_PATH_HERE );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 7 years 3 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

  • JeanFleu
  • JeanFleu
  • OFFLINE
  • Posts: 45
  • Thanks: 1
  • Karma: 0
7 years 3 weeks ago #299739 by JeanFleu
Replied by JeanFleu on topic problem cb code
I tried but did not print well: here's the code let me see how I should do since it's not possible to write the php code as it should be done within the field:

$utente= [user_id] ;
$i=0;
$date_test = Dates;
$testo="[cb_dates]";

$url = ($_SERVER );

$result = mysql_query('select * from yourfitness_tornei');
while (($row = mysql_fetch_assoc($result))) {
if ( [user_id] ==$utente) {

$dataArray[$i]=$testo;
$tournamentArray[$i]=[cb_tournament_name];
$surfArray[$i]=[cb_surface];
$repoArray[$i]=[cb_repos];
$scoreArray[$i]=[cb_scores];
$i++;
}
}

$tab = null;

$i=$i-1;
$i>0;
for (
$cont=1;
$cont<8;
$cont++ ) {
$tab .= "<table><tr><td style='background: #e9ff46; border-radius: 17px; text-align: -webkit-center;'><b> $date_test :</b> $dataArray[$i]</td></tr>
<tr><td style='background: #e9ff46;border-radius: 17px; text-align: -webkit-center;'><b>Tournament name: </b> $tournamentArray[$i]</td></tr>
<tr><td style='border-bottom: 2px solid #e9ff46;'><b>Surface: </b> $surfArray[$i]</td></tr>
<tr><td style='border-bottom: 2px solid #e9ff46;'><b>Tournoi/Repos/Preparation? </b> $repoArray[$i] </td></tr>
<tr><td style='border-bottom: 2px solid #e9ff46;'><b>Resultats et scores: </b> $scoreArray[$i] </td> </tr>
</table> <br/>";
}
return $tab;

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
7 years 3 weeks ago - 7 years 3 weeks ago #299742 by krileon
Replied by krileon on topic problem cb code
I can not help you with custom coding, sorry. For example the below are not valid.

This will error if the substitution is not an integer (treat all substitutions as strings and place them in quotes)
Code:
$utente= [user_id] ;

This will throw a fatal error:
Code:
$date_test = Dates;

I've no idea what you're trying to do here, but that's not how you get the current URL:
Code:
$url = ($_SERVER );

You should be using Joomla or CB API to access your database:
Code:
$result = mysql_query('select * from yourfitness_tornei'); while (($row = mysql_fetch_assoc($result))) {

This will all error unless all of these substitutions are guaranteed to be integers or booleans. Substitutions should always be treated as strings be placed in quotes:
Code:
$tournamentArray[$i]=[cb_tournament_name]; $surfArray[$i]=[cb_surface]; $repoArray[$i]=[cb_repos]; $scoreArray[$i]=[cb_scores];

Folks I am not here to analyze and debug your custom code. I'm sorry, but we just don't have the resources to provide such support.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 7 years 3 weeks ago by krileon.

Please Log in or Create an account to join the conversation.

  • JeanFleu
  • JeanFleu
  • OFFLINE
  • Posts: 45
  • Thanks: 1
  • Karma: 0
7 years 3 weeks ago #299754 by JeanFleu
Replied by JeanFleu on topic problem cb code
the table inside the variable $tab is seen but the values ​​taken is always the same I need to take the last seven recorded in the table you see in the code, how can I make it work?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
7 years 3 weeks ago #299789 by krileon
Replied by krileon on topic problem cb code

the table inside the variable $tab is seen but the values ​​taken is always the same I need to take the last seven recorded in the table you see in the code, how can I make it work?

Write the code to do just that. Your query would need to utilize order by and limit. Again, we're not here to assist with custom coding.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • JeanFleu
  • JeanFleu
  • OFFLINE
  • Posts: 45
  • Thanks: 1
  • Karma: 0
7 years 3 weeks ago #299800 by JeanFleu
Replied by JeanFleu on topic problem cb code
Kyle is not a problem of code.. because we tested it on a php file and it works!!
This is an FUNCTIONING code but here don't work!!!! Why????
Code:
<html> <body> <? $utente = 540; $i=1; $cont=0; $m=""; $m1= array(); $myArray= array(); $p=0; $dates=""; $tournament=""; $surface=""; $repos=""; $score=""; $dataArray= array(); $nameArray= array(); $surfArray= array(); $repoArray= array(); $scoreArray= array(); $resource = mysql_connect("localhost", "lepetit", "qGHu5K8MhY4q"); mysql_select_db("lepetit_tigaprove", $resource); $res = mysql_query('select * from yourfitness_comprofiler'); while($row = mysql_fetch_assoc($res)) { if ($row[user_id] ==$utente){ //nel primo ciclo cancelliamo i testi e acquisizione variabili $m="".$row[cb_dates]."".$row[cb_tournament_name]."".$row[cb_surface]."".$row[cb_repos]."".$row[cb_scores]; $dates=$row[cb_dates]; $tournament=$row[cb_tournament_name]; $surface=$row[cb_surface]; $repos=$row[cb_repos]; $score=$row[cb_scores]; } } $resulto = mysql_query ('select * from yourfitness_tornei'); while (($row = mysql_fetch_assoc ($resulto))) { $m1[$p] = "".$row[cb_use].""; } $q=$p-1; if ($m!=$m1[0]){ mysql_select_db('lepetit_tigaprove'); $toinsert = "INSERT INTO yourfitness_tornei (user_id,cb_dates,cb_tournament_name,cb_surface,cb_repos,cb_scores,cb_use) VALUES ('$utente','$dates','$tournament','$surface','$repos','$score','$m')"; mysql_query($toinsert); } $result = mysql_query('select * from yourfitness_tornei'); while (($row = mysql_fetch_assoc($result))) { if ($row[user_id] ==$utente){ //nell'ultimo ciclo $dataArray[$i]=$row[cb_dates]; $tournamentArray[$i]=$row[cb_tournament_name]; $surfArray[$i]=$row[cb_surface]; $repoArray[$i]=$row[cb_repos]; $scoreArray[$i]=$row[cb_scores]; $i++; } } $cont=1; while ($cont<8){ $i=$i-1; if ($i>0){ echo "<table style='width: 50%;'>"; echo "<tr><td style='background: #e9ff46; border-radius: 17px;'><b> 'cb_dates' :</b> " .$dataArray[$i]."</td></tr> <tr><td style='background: #e9ff46;border-radius: 17px;'><b>Tournament name: </b> ".$tournamentArray[$i]."</td></tr> <tr><td style='border-bottom: 2px solid #e9ff46;'><b>Surface: </b> ".$surfArray[$i]."</td></tr> <tr><td style='border-bottom: 2px solid #e9ff46;'><b>Tournoi/Repos/Preparation? </b>".$repoArray[$i]." </td></tr> <tr><td style='border-bottom: 2px solid #e9ff46;'><b>Resultats et scores: </b>".$scoreArray[$i]; echo "</td></tr></table>"; echo '<br>'; } $cont++; } ?> </body> </html>
P.S. also using return here it doesn't works

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum