kenrbnsn
Staff Alumni-
Posts
8,234 -
Joined
-
Last visited
Everything posted by kenrbnsn
-
This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=335739.0
-
This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=335733.0
-
Why are you posting in the PHP section. This should be in the Javascript section. Moving this there now. Ken
-
This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=335729.0
-
Unexpected behavior using ORDER BY ASC/DESC
kenrbnsn replied to babiez4sale's topic in PHP Coding Help
We need to see more of your code. Please post your code between tags. Ken -
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
-
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
-
[PHP] Problem with function move_uploaded_file()
kenrbnsn replied to GarryOne's topic in PHP Coding Help
What's the question? You just showed us some code without telling us what's wrong. Ken -
You can't put an if statement in a string like that. What are you trying to accomplish? Ken
-
This function can be written much simpler: <?php function copyyear($setyear){ return ("© $setyear" . ((date('Y') != $setyear)?" - " . date('Y'):'')); } ?> Ken
-
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
-
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
-
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
-
mail() function keeps outputting the message parameter as html
kenrbnsn replied to j.smith1981's topic in PHP Coding Help
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 -
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
-
Please post the code that's used to obtain the array values. Ken
-
mail() function keeps outputting the message parameter as html
kenrbnsn replied to j.smith1981's topic in PHP Coding Help
Is that all your code? Ken -
This is more of an HTML or CSS question, not PHP. For HTML, use tables. For CSS use floats (left or right). Ken
-
Using this code <?php $sort_by='<form action="'.(isset($_GET['q']) ? './index.php' : './store.php').'" method="GET">'; ?> works correctly. Ken
-
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
-
What is the error you're getting? Ken
-
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
-
PHP / AJAX / JavaScript Array Structure Fails
kenrbnsn replied to unemployment's topic in PHP Coding Help
You probably should do some debugging using Firebug & Firefox to see what you're actually passing back to the Javascript. Ken -
PHP / AJAX / JavaScript Array Structure Fails
kenrbnsn replied to unemployment's topic in PHP Coding Help
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 -
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