-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Rotate image string vertical, i.e. top to bottom
Ch0cu3r replied to D.Rattansingh's topic in PHP Coding Help
I used imageflip to flip the image horizontally and vertically so the text appears to be written from top to bottom. header('Content-type: image/png'); // create a 100*100 image $im = imagecreatetruecolor(100, 100); // Write the text $textcolor = imagecolorallocate($im, 0xFF, 0x00, 0xFF); imagestringup($im, 3, 40, 80, 'gd library', $textcolor); // write text bottom to top /* Flip the image, so text is top to bottom */ imageflip($im, IMG_FLIP_HORIZONTAL); imageflip($im, IMG_FLIP_VERTICAL); echo imagepng($im); imagedestroy($im); -
How to use a variable function as a callback
Ch0cu3r replied to CrimpJiggler's topic in PHP Coding Help
You are getting that error because you are defining the myCallback function more than once, eg // define myCallback for first time function myCallback ($matches) { // SOME CODE } $bbcode = preg_replace_callback($pattern1,'myCallback',$bbcode); // callback #1 // define myCallback a second time function myCallback ($matches) { // SOME CODE } $bbcode = preg_replace_callback($pattern2,'myCallback',$bbcode); // callback #2 it is ok to have multiple calls to the same callback function // define myCallback once function myCallback ($matches) { // SOME CODE } $bbcode = preg_replace_callback($pattern1,'myCallback',$bbcode); // callback #1 $bbcode = preg_replace_callback($pattern2,'myCallback',$bbcode); // callback #2 -
or it could mean the code is causing an error. Check your servers error log or enable error reporting at the top of the script ini_set('display_errors', 'On'); error_reporting(E_ALL); As a side note I think it would be better if you performed your queries using the database object ($wpdb) provided by wordpress rather than using the mysql_* functions
-
This is what your code should be <?php if($post->post_type=='event') { $q1=mysql_query("SELECT * FROM table_name WHERE type = 1 AND cat = $post->ID "); if (mysql_num_rows($q1)) { $row_diamond=mysql_fetch_object($q1); ?> <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td> <td id="diamond2" width="190"> <a href="<?=$row_diamond->website?>" title="<?=$row_diamond->website_title?>" target="_blank" style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br /> </td> <?php } else{ ?> <td width="115" align="right" valign="middle" id="diamond1"> </td> <td id="diamond2" width="190"> </td> <?php } } ?>
-
mod_rewrite is not a PHP extension! It is an Apache module, which you can enable in the httpd.conf
-
You need to check both variables values if ($_POST['blogarticle'] == "" || $_POST['blogtopic' ] == "") { // one or bott fields are empty } // OR alternatively use if (empty($_POST['blogarticle']) || empty($_POST['blogtopic' ])) { // one or both fields are empty }
-
Where is $blogarticle and $blogtopic defined? If you have not defined them yet then you need to use $_POST['blogarticle'] and $_POST['blogtopic'] instead.
-
Not get session in my chat apps
Ch0cu3r replied to IlaminiAyebatonyeDagogo's topic in PHP Coding Help
When the user logs in does your website login code set the users id to the $_SESSION['id'] variable? Also as paddyfields said you must call session_start() in order for the $_SESSION data to persist. -
Not get session in my chat apps
Ch0cu3r replied to IlaminiAyebatonyeDagogo's topic in PHP Coding Help
freichat requires the users id not their username! The three steps you need to do are listed in the wiki -
It is a domain resolution problem. Computers need to convert a domain name into an address in order to now where the device is located. The domain resolution is done via DNS this is what could be causing the delay.
-
How can i add a span element to this snippet of php
Ch0cu3r replied to darbeey's topic in PHP Coding Help
Change echo "<span class=\"$cf_i\">" . str_ireplace(';', "</span>, <span class=\"$cf_i\">", substr($i->fields[$cf_active_all[$cf_i]],1,-1) . '</span>'); to $fields = explode(';', substr($ifields[$cf_active_all[$cf_i]],1,-1)); $classes = array('odmb', 'odcr', 'odmb', 'odlgv', 'odtr'); foreach($fields as $key => &$field) { $field = '<span class="'.$classes[$key].'">'.$field.'</span>'; } echo implode(', ', $fields); -
How can i add a span element to this snippet of php
Ch0cu3r replied to darbeey's topic in PHP Coding Help
What is the output of these statements printf('<pre>%s</pre>', print_r($i->fields, true)); printf('<pre>%s</pre>', print_r($cf_active_all, true)); What classes are you wanting to apply and to which fields? -
How can i add a span element to this snippet of php
Ch0cu3r replied to darbeey's topic in PHP Coding Help
If all fields are going to have the same class then replace $cf_i with the name of the class you want to apply. If you want separate classes for each field then you will need to post more code, and what fields require which class. -
Does it improve if you use 127.0.0.1 instead of (localhost $dsn = 'mysql:host=127.0.0.1;port=3306;dbname=MyDatabase;charset=UTF8'; That code has got nothing to do with how long the script took to execute. It returns the memory usage. You should not be using this to determine how long your script took to execute. EDIT: To time script execution you'll want to use something like the examples here
-
Then change echo to $xml .=
-
How can i add a span element to this snippet of php
Ch0cu3r replied to darbeey's topic in PHP Coding Help
Not sure but you could try echo "<span class=\"$cf_i\">" . str_ireplace(';', "</span>, <span class=\"$cf_i\">", substr($i->fields[$cf_active_all[$cf_i]],1,-1) . '</span>'); If not you'll need to post more code -
php forms generated from mysql and submit
Ch0cu3r replied to Orionsbelter's topic in PHP Coding Help
By wrapping your input fields within <form></form> tags <form action="file/to/process/form.php" method="post"> // your form fields here </form> -
How can i add a span element to this snippet of php
Ch0cu3r replied to darbeey's topic in PHP Coding Help
$b_i is a variable which is being used as an array key for $diddy_all. Maybe you mean to add the span to the echo? echo "<span class=\"$b_i\">" . str_ireplace(';', ', ', substr($i->fields[$diddy_all[$bi_i]],1,-1)) . "</span>"; -
You'll need to strip the number formatting when finding the minimum value. A modification of Barands code $min = 99999.99; foreach($xml->xpath('//Company') as $co) { if ($co->SLevel != '-') { $min = min($min, str_replace(',', '', $co->SLevel)); // strip number formatting } } $min = number_format($min, 2, ',', '.'); // format minimum value foreach( $xml->xpath("//Company[SLevel='$min']") as $lowest) { echo "$lowest->Name : $lowest->SLevel<br>"; }
-
Ok, then use function setValue($fieldValue, $joinValue = ''){ $trimValue = trim(str_replace(array(' ','\t','\n','\r','\0','\x0B'), '', ($fieldValue))); return empty($trimvalue) ? 'No' : $joinValue . $trimvalue; } $xml .= "\t<soundPath>" . setValue($row['soundPath'], 'www.some url.com/somefolder/'). "</soundPath>\n";
-
$complaint should be $debtor on line 94
-
You just call mysq_real_escape_string on the users value $comp = $_GET['comp']; $sql="SELECT complain FROM complaint c WHERE c.d_name = '" . msyql_real_escape_string($comp) . "'";
-
If $row['soundPath'] contains the actual path then use $xml .= "\t<soundPath>" . fieldExists($row['soundPath']) . "</soundPath>\n";