
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
Just to shorten that, to make it look a little nicer: $selected = ($_GET['value'] == $option_value) ? 'selected="selected" : NULL;
-
Yes, and that's exactly how you do it.
-
If there's an 8-hour difference and you want it to display your time you can use: date('whatever format', time()+3600*;
-
Something like.. $trans = imagecolorallocate($img, 255, 255, 255); imagecolortransparent($img, $trans); ?
-
Show us your query.
-
PHP grabbing url for string after question mark
Alex replied to phpfreakjav's topic in PHP Coding Help
$variable = $_POST['xy']; Or request if it's coming from the URL.. $variable = $_REQUEST['xy']; -
[SOLVED] PHP string conversion: "The Matrix" to "Matrix, The"
Alex replied to mejpark's topic in PHP Coding Help
Ahh, I never knew that Use this then: function changeTitle($title) { $parts = explode(' ', $title, 2); return $parts[1] . ', ' . $parts[0]; } $title = 'The Matrix'; $new_title = (strtolower(substr($title, 0, 3)) == 'the') ? changeTitle($title) : $title; echo $new_title; If the title was 'The Matrix' it would output Matrix, The . If it was 'The Matrix Reloaded' it would output Matrix Reloaded, The. Edit: The third parameter in explode() doesn't work like that.. So it had to actually be 2. -
[SOLVED] PHP string conversion: "The Matrix" to "Matrix, The"
Alex replied to mejpark's topic in PHP Coding Help
function changeTitle($title) { $parts = explode(' ', $title); return $parts[1] . ', ' . $parts[0]; } $title = 'The Matrix'; $new_title = (strtolower(substr($title, 0, 3)) == 'the') ? changeTitle($title) : $title; echo $new_title; Output: Matrix, The However, that won't work for titles that contain more than 3 words and the word 'the'. How would you want want the title to change if it was like 'The something something'? I can change the function for you if necessary. -
It says 'if it doesn't equal on or it doesn't equal off'. So it will always run.
-
$sql=mysql_query('SELECT * FROM member_messages WHERE status = "NEW" and user_id ="' . $userid . '"');
-
What do you mean check-again? The results aren't going to change within the execution of the script...
-
strpos(). $myVariable = 'may the force be with you'; if(strpos($myVariable, 'the force') === false) { //the string was not found } else { //It was found.. }
-
Any free php hosting site which allows to create dynamic images?
Alex replied to john_bboy7's topic in Miscellaneous
Well I don't know what you're talking about.. I used 000webhost before I had my own hosting, it was great. -
Depending on your situation it's sometimes useful just to make a function like user_exists(), you could input a username and it would return true or false, the core of that function could look like: $result = create_query('some query..'); if(!mysql_num_rows($result)) { return false; } return true;
-
[SOLVED] Simple, Simple php stats script not working
Alex replied to patheticsam's topic in PHP Coding Help
Also a problem with your second query.. mysql_query(' UPDATE stats SET `visit`="' . $stats . '" WHERE id = "1"') or die(mysql_error()); -
[SOLVED] Simple, Simple php stats script not working
Alex replied to patheticsam's topic in PHP Coding Help
$stats = ++$data['visit']; You could use the ++ before or after the variable. It's suggested you use it before because it won't alter the value of $data['visit'], but unless you're using that again and want the original value it doesn't matter. -
[SOLVED] script not running when executed with cron
Alex replied to benphelps's topic in PHP Coding Help
I believe I read something about the paths for things on CRON files have to be different because of the way they're ran. So try making them in terms of the root, eg. instead of fork.php try ../whatever/fork.php (or however yours is setup). However, if that fails I also encountered a similar problem with CRON and a php script utilizing MySQL, which I wasn't even including anything on.. and I still couldn't get it to work. It was strange. -
The reason I didn't do it like that is because then you manually have to append the closing paragraph tag. I guess it's not to bad since you also have to append the link.
-
If every paragraph ends with '</p>' you can use something like this: $row = mysql_fetch_assoc($result); //From the query you made.. $output = str_replace('</p>', '</p>{END_PARAGRAPH}', $row['entry']); // Or whatever row you have the article in.. $output = explode('{END_PARAGRAPH}', $output); echo $output[0];
-
[SOLVED] How can i use dynamic image in phpbb forum?
Alex replied to john_bboy7's topic in PHP Coding Help
But i want the opposite,..that a .php would be read as a .png Because i am having 5 png images and 1 php files.. at every refresh the image changes here is my actual code: <?php Header ("Content-type: image/png"); $a=array( '1.png', '2.png', '3.png', '4.png', '5.png' ); $b=$a[array_rand($a)]; $img_handle = imageCreateFrompng("$b"); Imagepng ($img_handle); ImageDestroy ($img_handle); ?> No. That is what you want.. You can save that code as a .png file.. And when visiting you'll be visiting like image.png .. -
[SOLVED] How can i use dynamic image in phpbb forum?
Alex replied to john_bboy7's topic in PHP Coding Help
You can use a .htaccess file to make it so that a .png would be read as a .php. eg. <Files "index.png"> AddType application/x-httpd-php .png </Files> You could then have a file named 'index.png' with your source it in, and you could view it as index.png but the server would still process it like .php -
Not.. if (!$_POST['update']) { Use: if (isset($_POST['update'])) {
-
Use: if(isset($_POST['something']) && isset($_POST['somethingelse'])).. Instead of: if($_POST['post']).. Also, why would you have the date as a text field? They could put whatever they want. You should use date as a unix time stamp. You can use time(), and when fetching the blog posts use date()
-
That's what he was doing originally, just forgetting the 'echo'. That's what I thought he meant.
-
It's not a hack. It's the 'correct' way. 'echo' just means that it's outputting it to the browser.