Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,156,733 members, 7,831,335 topics. Date: Friday, 17 May 2024 at 05:15 PM

Post your PHP Problems Here - Webmasters (5) - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Post your PHP Problems Here (63413 Views)

Thread For All Your Blogging Related Problems Here / Get And Request For Your Php Problems Here / Connecting To Your Gmail Account From Your Php Application. (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (20) (Reply) (Go Down)

Re: Post your PHP Problems Here by dexed(m): 6:49pm On Oct 18, 2013
sunday478: ^^Yeah, I understand. Just the wampXamp stuff now. Am yet to download it.
You can use WAMP(Windows Apache Mysql PHP), it also comes with phpadmin, sqlbuddy, webgrind n the total package is about 25mb
Re: Post your PHP Problems Here by sunday478(m): 8:38pm On Oct 18, 2013
dexed:
You can use WAMP(Windows Apache Mysql PHP), it also comes with phpadmin, sqlbuddy, webgrind n the total package is about 25mb
wow, I will go for that.
Re: Post your PHP Problems Here by elvis10ten(m): 8:59am On Oct 19, 2013
bowofolu: I have problems making upload scripts. Can you help me on that.

I don't have a good knowledge of php. How do i learn php.
you should face your number one problem, learning php and mysql first. What you need now will fall in when you do. There are many free file sharing scripts also, you can tear it up and get how they upload.
Re: Post your PHP Problems Here by Nobody: 10:03am On Oct 19, 2013
@elvis

What's the Use of ob_start and ob_flush in echoing out stuffs??

Which is more safer to use btw include.php and require.php??
Re: Post your PHP Problems Here by Nobody: 10:34am On Oct 19, 2013
Include and Require are about the same thing.

This first example will not display any output
<?php 
ob_start();
echo "Hello y'all,";
$date=date("F j, Y"wink;
echo "Today's date is $date.";
ob_end_clean();
?>


Now, compare that code with this:
<?php 
ob_start();
echo "Hello y'all,";
$date=date("F j, Y"wink;
echo "Today's date is $date.";
$content=ob_get_contents();
ob_end_clean();

echo "The buffered contents are: $content";
?>

You will get an output like this:
The buffered contents are: Hello y'all,Today's date is October 19, 2013.
Re: Post your PHP Problems Here by elvis10ten(m): 10:53am On Oct 19, 2013
Djangocode: @elvis

What's the Use of ob_start and ob_flush in echoing out stuffs??

Which is more safer to use btw include.php and require.php??

I used the ob_start and ob_flush as a workaround for the error (header already sent).
Include and require does the same thing except when an error occurs.
require will produce a fatal error and stop the script
include will only produce a warning and the script will continue to run.
Re: Post your PHP Problems Here by Nobody: 12:51pm On Oct 19, 2013
@Dhtml

Thanks Boss.. Now I understand.. U used ob_start() and ob_end_clean() at the end.. I only know of ob_flush().. Is it a must to use it??

So ob_start() outputs any code or variables that are declared upon starting it..

I also noticed u using the ob_get_contents as the value of a variable so as to echo the variable later.. That's good..

What is the best time to use this function(ob_start) in PHP??

U said require n Include are the same thing. How come Require throws a fatal error and terminates the next script?? Are there no security threats attached to include executing scripts even when an error Occurs??

Forgive my Naïve questions..

@elvis.. Thanks for Yo Explanation..
Re: Post your PHP Problems Here by dexed(m): 2:42pm On Oct 19, 2013
Djangocode: @Dhtml

Thanks Boss.. Now I understand.. U used ob_start() and ob_end_clean() at the end.. I only know of ob_flush().. Is it a must to use it??

So ob_start() outputs any code or variables that are declared upon starting it..

I also noticed u using the ob_get_contents as the value of a variable so as to echo the variable later.. That's good..

What is the best time to use this function(ob_start) in PHP??

U said require n Include are the same thing. How come Require throws a fatal error and terminates the next script?? Are there no security threats attached to include executing scripts even when an error Occurs??

Forgive my Naïve questions..

@elvis.. Thanks for Yo Explanation..
the ob means output buffering, its used to stop php from sending output to the browser, everything that would have been printed to the client is delayed and can be stored in a variable, this can be useful in caching.
ob_flush releases the stored output from memory.
Re: Post your PHP Problems Here by Nobody: 4:01pm On Oct 19, 2013
Let us assume that you have a php script like this:

<?php
include 'config.php';
header('location:home.php');
?>
For some reasons maybe config.php has outputed a space or some unreadable character and your redirect does not work and you start having headers already sent error. All you need to do is:
<?php
ob_start();
include 'config.php';
header('location:home.php');
?>
This will start output buffering and the redirect will work.
Another way of doing this is :
<?php
ob_start();
include 'config.php';
ob_end_clean();
header('location:home.php');
?>
This will thrash any output sent by config.php
In fact if config.php echoes hello world - the output will never be rendered on the screen
Re: Post your PHP Problems Here by Nobody: 7:01pm On Oct 19, 2013
@Dhtml

Thanks Brov.. Its Clearer Now..

About My security question on include.php?? Any ideas??
Re: Post your PHP Problems Here by Nobody: 8:04pm On Oct 19, 2013
You are welcome, the include.php question is not clear to me, you know i have not been following this thread properly from the start. .
Re: Post your PHP Problems Here by elvis10ten(m): 8:53pm On Oct 19, 2013
Djangocode: @Dhtml

Thanks Brov.. Its Clearer Now..

About My security question on include.php?? Any ideas??
use require if the script really need the file to run, use include if it doesn't matter. I would say require is more better security wise.
Re: Post your PHP Problems Here by Nobody: 9:45pm On Oct 19, 2013
Very true
Re: Post your PHP Problems Here by Nobody: 11:00pm On Oct 19, 2013
@Dhtml

Thanks Brov... Quite Definitive now..

Further Questions might Arise..
Re: Post your PHP Problems Here by Nobody: 7:36am On Oct 20, 2013
We shall be expecting them questions. . .
Re: Post your PHP Problems Here by Nobody: 11:57am On Oct 20, 2013
Please how do i link a file to a particular menu, or sub-menu. after creating the file.

Thank you.
Re: Post your PHP Problems Here by Nobody: 7:22pm On Oct 20, 2013
Linking menu and submenu is an html thing and not php.

1 Like

Re: Post your PHP Problems Here by sunday478(m): 7:47am On Oct 22, 2013
sunday478: ^^Yeah, I understand. Just the wampXamp stuff now. Am yet to download it.
sunday478: wow, I will go for that.
dexed:
You can use WAMP(Windows Apache Mysql PHP), it also comes with phpadmin, sqlbuddy, webgrind n the total package is about 25mb
i have download it, thanks for ur supported. +over to my scripts now
Re: Post your PHP Problems Here by youngeconomist(m): 6:30pm On Oct 22, 2013
Fellow nairalanders, l wish to know how to create a user-interface through php and connect it to oracle database 11.2g which is running on windows 7. Please, what and what do l need to do?
Re: Post your PHP Problems Here by Nobody: 3:47pm On Oct 24, 2013
@Members

Anyone here ever Used Laravel.. What's the installation process.. That's all I needa know.. I wanna install and run it on Localhost so as to boost my developing speed..

Any Ideas..

Thanks Y'all..
Re: Post your PHP Problems Here by phpier: 9:52pm On Oct 24, 2013
please can sum1 here tell me hw i can rewrite url paths of a php file, so that instead of sample.php i would av just sample ... I tried to google it but wasnt realy satisfied with wat i got .
Re: Post your PHP Problems Here by Oohrhii(m): 3:56am On Oct 25, 2013
Please how do i truncate a record pulled from data base while displaying it i have been trying to work on the codes but cant really get it.. the best i was able to do was to put it in a text area.and limit it by width and number of line. .. using this code:

<textarea name="textarea" cols="35" rows="3"><?php echo $row_rsMa['pd_description']; ?></textarea>

Please help me oh! as i don't want to use textarea.
Re: Post your PHP Problems Here by adewasco2k(m): 6:32am On Oct 25, 2013
Oohrhii: Please how do i truncate a record pulled from data base while displaying it i have been trying to work on the codes but cant really get it.. the best i was able to do was to put it in a text area.and limit it by width and number of line. .. using this code:

<textarea name="textarea" cols="35" rows="3"><?php echo $row_rsMa['pd_description']; ?></textarea>

Please help me oh! as i don't want to use textarea.

dont know how you are handling or pulling your text from your database but you can implement this


<?php

$message = "This message is so long and i want to truncate it";

echo substr($message, 0, 12);

?>

//That should echo

This message




the use of substr($message, 0, 13):

$message= you text pulled from database

0= is the index where the truncate will start, i used 0 so it will start from the first character if you want it to start from behind you can use -1

12= is the length of the truncate like in the example by counting the characters it will stop at the index 12
Re: Post your PHP Problems Here by adewasco2k(m): 6:34am On Oct 25, 2013
phpier: please can sum1 here tell me hw i can rewrite url paths of a php file, so that instead of sample.php i would av just sample ... I tried to google it but wasnt realy satisfied with wat i got .

this is what you are looking for .htaccess create a .htaccess file (open a new notepad copy the below code into it save as htaccess as it has been saved go back and rename from htaccess to .htaccess by adding a dot in from of the name htaccess) place the .htaccess in your root directory

Didnt test this but give it a try


RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ /$1.php [QSA]
Re: Post your PHP Problems Here by Nobody: 6:41am On Oct 25, 2013
Djangocode: @Members

Anyone here ever Used Laravel.. What's the installation process.. That's all I needa know.. I wanna install and run it on Localhost so as to boost my developing speed..

Any Ideas..

Thanks Y'all..

Any Solutions.. I always get errors when tryna run localhost/laravel/public..
Re: Post your PHP Problems Here by adewasco2k(m): 6:45am On Oct 25, 2013
^ just thought of something if you are trying to handle a problem like having http://mysite.com/unlocking.php/blackberry and you want http://mysite.com/unlocking/blackberry you might need to rewrite the code to only remove php extention that is been followed by a slash .php/ and not when a url is ending with .php like http://mysite.com/unlocking.php so it depends what you want REGEXP will do that for you
Re: Post your PHP Problems Here by Nobody: 6:55am On Oct 25, 2013
adewasco2k: ^ just thought of something if you are trying to handle a problem like having http://mysite.com/unlocking.php/blackberry and you want http://mysite.com/unlocking/blackberry you might need to rewrite the code to only remove php extention that is been followed by a slash .php/ and not when a url is ending with .php like http://mysite.com/unlocking.php so it depends what you want REGEXP will do that for you

Have googled it though n I aint seen a clear explanation.. They said sumfn like getting a Composer and running it on command line interface.. Its Kinda Tedious though.. That's y I asked whether anyone have used it..
Re: Post your PHP Problems Here by adewasco2k(m): 7:11am On Oct 25, 2013
@Djangocode sorry I was typing that when you posted so my post was pointing to you, was actually referring to my own post about rewriting url.

Back to laravel, what error are you having? Thoigh I have it installed on my PC I haven't produced anything with it yet, what I can do it remove my and install again so I can remember all the hassles.

I remember facing problems with file permission because the folder should have file permission 777
Re: Post your PHP Problems Here by Nobody: 8:56am On Oct 25, 2013
adewasco2k: @Djangocode sorry I was typing that when you posted so my post was pointing to you, was actually referring to my own post about rewriting url.

Back to laravel, what error are you having? Thoigh I have it installed on my PC I haven't produced anything with it yet, what I can do it remove my and install again so I can remember all the hassles.

I remember facing problems with file permission because the folder should have file permission 777

Aii Sir.. When u are done with the re-installation.. Lemme Know..

Thanks Brov..
Re: Post your PHP Problems Here by Oohrhii(m): 10:56am On Oct 25, 2013
adewasco2k:

dont know how you are handling or pulling your text from your database but you can implement this


<?php

$message = "This message is so long and i want to truncate it";

echo substr($message, 0, 12);

?>

//That should echo

This message




the use of substr($message, 0, 13):

$message= you text pulled from database

0= is the index where the truncate will start, i used 0 so it will start from the first character if you want it to start from behind you can use -1

12= is the length of the truncate like in the example by counting the characters it will stop at the index 12


Bro thank you for this..

I actually do pull the record from the data base using recordset and these are the parameters...

This echo $row_rsMa['pd_description'] pulls record from database through recordset created and pd_description is the field name from the database.

I will try the format you sent to see if it will fetch records before adjusting it to required content length. Thanks once again for your prompt reply.
Re: Post your PHP Problems Here by elvis10ten(m): 9:17pm On Oct 25, 2013
@ adewasco2k, thanks for helping out with this thread while i was not around.

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (20) (Reply)

Add More Than One Website Url To Your Twitter Account. / Top Google Searches By Nigerians 2015;Arsenal,Buhari,Diezani Arrest tops d list. / Mark Zuckerberg Eating Pounded Yam And Eforiro (Photo)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 48
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.