Jump to content

kenrbnsn

Staff Alumni
  • Posts

    8,234
  • Joined

  • Last visited

Everything posted by kenrbnsn

  1. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=335739.0
  2. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=335733.0
  3. Why are you posting in the PHP section. This should be in the Javascript section. Moving this there now. Ken
  4. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=335729.0
  5. We need to see more of your code. Please post your code between tags. Ken
  6. It looks like you need to use another single quote to escape a single quote when using odbc queries, so if you have the string <?php $str = "woody'squote@example.net" ?> to use it in a odbc query, you could do <?php $str = str_replace("'","''",$str); ?> before using it. Ken
  7. To shorten this code, I would use variable variables. I would also make each of the variables line $avi0, $avi1 into arrays. <?php $vars = array('avi'=>2,'mkv'=>3,'ogm'=>2,'mp4'=>2); $query = exec_mysql_query("SELECT * FROM sources WHERE cat_id = '$cid' AND id = '$id' LIMIT 1"); while ($row = mysql_fetch_assoc($query)) { foreach ($vars as $var => $max) { for($i=0;$i<$max;++$i) { ${$var}[$i] = $row["{$var}_{$i}"]; } } } ?> Note: this code is untested. Ken
  8. What's the question? You just showed us some code without telling us what's wrong. Ken
  9. You can't put an if statement in a string like that. What are you trying to accomplish? Ken
  10. This function can be written much simpler: <?php function copyyear($setyear){ return ("© $setyear" . ((date('Y') != $setyear)?" - " . date('Y'):'')); } ?> Ken
  11. Write the string as: <?php $t = '<a href="../'.(($r['accounttyperaw'] == '') ? 'c' : 'u').'/'.(($r['accounttyperaw'] == '') ? $r['companytag'] : $r['feedusername']).'">'.ucwords($r['feedfirstname'].' '.$r['feedlastname']).' has updated</a>'; ?> Ken
  12. You have to use an explicit index variable instead of "[]" so you can add the "avatar" to the array: <?php $i = 0; while (($row = mysql_fetch_assoc($query)) !== false) { $partners[$i] = array( 'id' => $row['id'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'username' => $row['username'], 'industry' => $row['industry'], 'stage' => $row['stage'], 'companyid' => $row['companyid'], 'companytag' => $row['companytag'], 'gender' => $row['gender'], 'accounttyperaw' => $row['accounttype'], 'accounttype' => ($row['accounttype'] == '1') ? 'Entreprenuer' : 'Investor', 'country' => $row['country'], 'state' => $row['state'], 'city' => $row['city'], 'approveddate' => $row['approved_date'], 'feedid' => $row['FeedId'], 'feedfirstname' => $row['FeedFirstName'], 'feedlastname' => $row['FeedLastName'], 'feedusername' => $row['FeedUserName'], 'action_id' => $row['action_id'], 'details' => $row['details'], 'display_name' => ucwords("${row['firstname']} ${row['lastname']}"), 'associate_name' => ucwords("${row['FeedFirstName']} ${row['FeedLastName']}"), ); //These conditionals should generate the avatars needed for the ajax. if (($row['accounttype'] == 0 || $row['accounttype'] == 1) && !empty($row['action_id'])) { if (($row['FeedId'] != $user_info['uid']) && (!empty($row['action_id'])) && ($row['accounttype'] !== '') && ($row['action_id'] != 'joinedcompany') && ($row['action_id'] != 'companyprofilepicture')) { $partners[$i]['avatar'] = getUserAvatar($row['FeedUserName']), } else if (($row['accounttype'] == '') || ($row['action_id'] == 'joinedcompany') || ($row['action_id'] == 'companyprofilepicture')) { $ctag = strtolower($row['companytag']), $partners[$i]['avatar'] = getCompanyAvatar($ctag), } else { $partners[$i]['avatar'] = getUserAvatar($row['username']), } } else if (($row['accounttype'] != '') && empty($row['action_id'])) { $partners[$i]['avatar'] = getUserAvatar($row['username']), } else if (($row['accounttype'] == '') && ($row['action_id'] == '')) { $ctag = strtolower($row['companytag']), $partners[$i]['avatar'] = getCompanyAvatar($ctag), } $i++; } ?> Ken
  13. You need to know something about wild-card filename matching in Linux (Unix). I have these files in my directory: tron_movie.txt tron_review0.txt tron_review1.txt tron_review2.txt tron_review3.txt tron_review4.txt Using this code <?php $x = glob('*review*.txt'); echo '<pre>' . print_r($x,true) . '</pre>'; ?> gets me Array ( [0] => tron_review0.txt [1] => tron_review1.txt [2] => tron_review2.txt [3] => tron_review3.txt [4] => tron_review4.txt ) Ken
  14. You're echoing the $message with this line: <p><?=(isset($message)) ? $message : '';?></p> BTW, you really shouldn't use short tags like "<?" instead of "<?php " and "<?=" instead of "<?php echo ". Ken
  15. Instead of using "!== NULL", try using "!= ''" in your code: <?php if($TheClub['addressL1'] != '') { echo "<li>{$TheClub['addressL1']}</li>"; } if($TheClub['addressL2'] != '') { echo "<li>{$TheClub['addressL2']}</li>"; } if($TheClub['addressL3'] != '') { echo "<li>{$TheClub['addressL3']}</li>"; } echo "<li>{$TheClub['area']}</li>"; echo "<li>{$TheClub['county']}<li>"; echo "<li>{$TheClub['country']}</li>"; echo "<li>{$TheClub['postcode']}</li>"; ?> Ken
  16. Please post the code that's used to obtain the array values. Ken
  17. This is more of an HTML or CSS question, not PHP. For HTML, use tables. For CSS use floats (left or right). Ken
  18. Using this code <?php $sort_by='<form action="'.(isset($_GET['q']) ? './index.php' : './store.php').'" method="GET">'; ?> works correctly. Ken
  19. Those email messages are encoded with Base64, to decode them use base64_decode. There should be a header in the email message telling you that the message is encoded. BTW, the decoded message is Ticker Coupon Maturity B/O Price B/O Yield Mid ASW Mid Z Axe ------------------------------------------------------------------------------ FMGAU 7 01-Nov-15 103.500/104.500 6.078 /5.822 436.8 447 FMGAU 6.375 01-Feb-16 101.250/102.250 6.058 /5.811 418.9 435 FMGAU 6.875 01-Feb-18 103.250/104.250 6.266 /6.084 378.5 395 s2.165mm Ken
  20. What is the error you're getting? Ken
  21. If you want individual links for each username, you need to re-work your code a little to build the link in the while loop & then echo all the links: <?php $find_members_online_q = "SELECT username, forum_rank FROM fans WHERE status = 'Online'"; $find_members_online_r = mysql_query($find_members_online_q); $find_members_online_c = mysql_num_rows($find_members_online_r); echo "<span style='font-weight:bold'>" . $find_members_online_c . " members</span> are online<br><br>"; $tmp = array(); while ($find_members_online_ro = mysql_fetch_array($find_members_online_r)) { $usr = ($find_members_online_ro["forum_rank"] == "Site Owner")?"<span style='color:#FF0000'>{$find_members_online_ro["username"]}</span>":$find_members_online_ro["username"]; $tmp[] = "<a href='../profile.php?action=view&username={$find_members_online_ro["username"]}'>$usr</a>"; } echo implode(', ',$tmp); ?> Ken
  22. You probably should do some debugging using Firebug & Firefox to see what you're actually passing back to the Javascript. Ken
  23. I find that when using AJAX with PHP, it is much easier to pass arrays from PHP back to Javascript if I use the JSON format. Since it looks like you're using the jQuery library, I would suggest you look at $.post or $.get as a simpler way of doing the AJAX code. Ken
  24. It's much easier to do as Pikachu suggested: <?php $tmp = array(); $query = "SELECT username FROM members"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $tmp[] = $row["username"]; } echo implode(', ',$tmp); ?> Ken
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.