Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,367 members, 7,815,784 topics. Date: Thursday, 02 May 2024 at 06:21 PM

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

Nairaland Forum / Science/Technology / Webmasters / Post your PHP Problems Here (63299 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) ... (14) (15) (16) (17) (18) (19) (20) (Reply) (Go Down)

Re: Post your PHP Problems Here by kentc3: 5:48pm On Feb 27, 2015
xyluz:


Try uploading the file without changing the name.

Try these debugging tips:

Did you check inside the images folder?
Is the image there?
If the image is there what name does it have?
Manually put an image inside the image folder (copy and paste), then try using your code to display the image...

Does it display the manually uploaded image?

Hope this was helpful?


Updated: check the image

Thank you very much, it is now working...... i remove the dirname, and moved the file to the directory straight, without changing the name of the file... SEE MY CHANGES BELOW

I replaced this
$newname=dirname().'/images1/'.$filename;
if(!file_exists($newname))
{
if((move_uploaded_file($_FILES['photo']['tmp_name'],$newname)))
{


with this below
$newname='images1/'.$filename;
if(!file_exists($newname))
{
if((move_uploaded_file($_FILES['photo']['tmp_name'],$newname)))
{


And it is now working..... Thanks, i really appreciate
Re: Post your PHP Problems Here by lovebondz(m): 7:29pm On Feb 27, 2015
kentc3:
This code Uploads a picture into a database, but when i try to retrieve it and display it, the result is blank... i need you guys assistant on how to overcome this coz i ve been stuck here for weeks.. i will really appreciate it... Below is the Upload Script

if(isset($_POST['submit']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$pic=$_FILES['photo']['name'];

if((!empty($_FILES['photo'])) && ($_FILES['photo']['error']==0))
{
$filename=basename($_FILES['photo']['name']);
$ext= substr($filename, strrpos($filename,'.')+1);
if(($ext == "jpg" || $ext == "gif" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG" || $ext == "PNG" || $ext == "png" || $ext == "GIF"wink &&($_FILES['photo']['size']<100000000))
{

$newname=dirname(__FILE__).'/images1/'.$filename;
if(!file_exists($newname))
{
if((move_uploaded_file($_FILES['photo']['tmp_name'],$newname)))
{

mysql_connect("Localhost","Gospel","gospel"wink or die("Could not connect"wink;
mysql_select_db("picture"wink or die("could not select db"wink;
$insert=mysql_query("INSERT INTO `pix`(`sn`, `fname`, `lname`, `image`) VALUES (NULL,'".$name."','".$email."','".$newname."')"wink or die("database not found"wink;
echo "<img src='$pic' alt='' height='300' width='500'>"."<br>";
echo "<img src='$newname' alt='' height='300' width='500'>"."<br>";
echo "its done! the file has been saved as:".$newname;
}
else
{
echo "Error! problem occured";
}}
else
{
echo "error file:".$_FILES['photo']['name']."already exist";
}}
else
{
echo "File format not supported";
}}
else
{
echo "thank you, no file uploadedd";
}


}


BELOW IS THE RETRIEVE AND DISPLAY SCRIPT

<?php
mysql_connect("Localhost","Gospel","gospel"wink or die("Could not connect"wink;
mysql_select_db("picture"wink or die("could not select db"wink;

$select=mysql_query("SELECT * from `pix` WHERE sn= 23 "wink or die("could not find"wink;
if(mysql_num_rows($select)==true)
{
$me=mysql_fetch_array($select);
?>
<img src="<?php echo $me['image']; ?>" alt="" height="200" width="120">
<?php
}
?>


Please i need a solution... Thanks


Properly check if a file is an image using exif-imagetype
Re: Post your PHP Problems Here by Vijon(m): 8:44pm On Feb 27, 2015
Adesege:
Create a folder in C:\wamp\www, say 'sample'. Then launch ur browser and access http://localhost/sample. Ensure your wampserver is on and has the green icon on the taskbar.

i did nd it seems to work.bt d older files stil cant b access
Re: Post your PHP Problems Here by exellent91(m): 10:59am On Feb 28, 2015
I need help. I need someone that is good at promoting website by getting more traffic,to help me in my site,http://megadownloads.moreforum.com. When the person signs up,he or she should pm me(send me private msg through the site to be made a moderator and an admin.thnx
Re: Post your PHP Problems Here by xyluz: 8:22am On Mar 02, 2015
Jregz:



side talk -- mysql extension is deprecated,use mysqli instead

Or PDO...
Re: Post your PHP Problems Here by xyluz: 8:24am On Mar 02, 2015
kentc3:


And it is now working..... Thanks, i really appreciate


You're welcome. Try to use either mysqli or PDO, mysql is deprecated.

I have a short tutorial on PDO:

http://xyluzcodes..com/2015/02/pdo-tutorial-series-6.html
Re: Post your PHP Problems Here by xyluz: 8:27am On Mar 02, 2015
exellent91:
I need help. I need someone that is good at promoting website by getting more traffic,to help me in my site,http://megadownloads.moreforum.com. When the person signs up,he or she should pm me(send me private msg through the site to be made a moderator and an admin.thnx


Nice effort. But still room for improvement.
Re: Post your PHP Problems Here by exellent91(m): 3:03pm On Mar 05, 2015
I need help from my fellow nairalanders, pls check this website, http://megadownloads.moreforum.com. I need help from every one of you to check my website and sign up because I need admins,(administrator) that will help me in running of the site. Or else the site will crash,plzzzzz, I need urgent help. Note: not just to checkout the website but also to sign up, so that I can be able to make you my admin,thanks. do this for a fellow nairalander cos we are like brothers.pls after signing up post on any of the threads to be made admin instantly
Re: Post your PHP Problems Here by Dreyson69: 12:13am On Mar 06, 2015
Elvisten10:
Hello,

If You need help or request solutions to problems on php, kindly post on this thread.

No matter how simple or complex it is, people are here to help.

Happy Coding smiley
Cheap Non Hosted Google adsense for Sale at 10k with verification Pin.. Whatsapp me if interested @08035253041
Re: Post your PHP Problems Here by xyluz: 9:34am On Mar 06, 2015
Dreyson69:
Cheap Non Hosted Google adsense for Sale at 10k with verification Pin.. Whatsapp me if interested @08035253041

Can you explain what you mean by Google adsense? undecided
Re: Post your PHP Problems Here by Adesege(m): 8:49am On Mar 07, 2015
For standard, it is not advisable to use the mail() function. Not that it's deprecated but there are less to what to you can do with it.

I'll recommend you use PHPMailer. With this, you can set headers, attach docs to mails and other great features.

adewasco2k:


Read up php function mail()

Also you should know about forms and POST/GET
Re: Post your PHP Problems Here by Adesege(m): 8:52am On Mar 07, 2015
It's usuall advisable to use the $_POST variable to send information to the server.

PHPMailer should be recommended instead.


Elvisten10:
all you need to know to achieve this is HTML FORM, PHP $_GET OR $_POST VARIABLES (ARRAY) AND PROBABLY THE PHP MAIL() FUNCTION. You write the html form and put the contact php script name as the value for the action attribute, then you get the submitted data with the $_GET or $_POST variables and probably send it to your mail using the mail function.
Re: Post your PHP Problems Here by Adesege(m): 9:05am On Mar 07, 2015
A sketch...

You'll need a html form, with the action attribute pointing to where your php form processor page is. Leave blank if the code is on the same page as the html form or put <?php echo $_SERVER["PHP_SELF"]; ?>. Don't forget to use POST as the method.

2. On your processing page, get the values by setting variables to it. E.g $mail=htmlspecialchars($_POST["email"]); The "email" key should correspond with the name you set in your html form. Also don't forget to sanitize your input.

You should have made a connection before now.

Example code:
<?php
if(isset($_POST["submit"]) && $_POST["submit"] !==""wink{
include("db.php"wink;
//set your variables and sanitize
$name=htmlspecialchars($_POST["name"]);
$mail=htmlspecialchars($_POST["mail"]);
$content=htmlspecialchars($_POST["content"]);
//do necessary if else

//insert into the db

//if insert, send mail();

//echo message

}
?>
turl:


Thought I would also be needing to add some database info. Guess I need to read up the whole tut. I got frustrated after the codes just stopped making sense and gave up. Thanks.
Re: Post your PHP Problems Here by Adesege(m): 9:07am On Mar 07, 2015
Have you gotten a solution, if not, let me know so i can work out something for you

blink182:
Please I need script that will make this form work. Thanks

http://ormedsupremeoption.com/new_distributor.html

I want it to mail the fields in the form to the company email
Re: Post your PHP Problems Here by Adesege(m): 9:09am On Mar 07, 2015
I learnt it cost a fortune to enroll in that institution

CODEEATER:
M starting my NIIT course really soon...

Just 4 cert sake... according to wat I hear dey don't teach much
Re: Post your PHP Problems Here by Nobody: 9:49am On Mar 07, 2015
Adesege:
Have you gotten a solution, if not, let me know so i can work out something for you

Ok, we solved it. Thanks.
Re: Post your PHP Problems Here by Adesege(m): 9:51am On Mar 07, 2015
Good to know.
Cheers
blink182:
Ok, we solved it. Thanks.

1 Like

Re: Post your PHP Problems Here by kentc3: 3:55pm On Mar 09, 2015
Good Day Guys, Please i will want to play videos on my website, but do not want to make use of the HTML5 Video tag to do that.... i tried using jw player but the process of setting up the ftp and embedding in my web page and so on, seems to be cumbersome.... please i will love someone to assist me with other ways of achieving this .... thanks. anticipating your replies.
Re: Post your PHP Problems Here by Adesege(m): 8:36pm On Mar 09, 2015
Try to take a look at jplayer or video.js. They are good plugin to achieve ur aim.

kentc3:
Good Day Guys, Please i will want to play videos on my website, but do not want to make use of the HTML5 Video tag to do that.... i tried using jw player but the process of setting up the ftp and embedding in my web page and so on, seems to be cumbersome.... please i will love someone to assist me with other ways of achieving this .... thanks. anticipating your replies.
Re: Post your PHP Problems Here by Debeloved87(m): 9:39pm On Mar 09, 2015
how can i shorten posts on the main page of the blog, that viewers will have to view the whole post by clicking "continue reading" ?
Re: Post your PHP Problems Here by kentc3: 10:51pm On Mar 09, 2015
Adesege:
Try to take a look at jplayer or video.js. They are good plugin to achieve ur aim.


Owk... thank you very much, i will try it out...
Re: Post your PHP Problems Here by ps3o(m): 1:06pm On Mar 11, 2015
Vijon:
gud day all,plz help me out wit dis-i cant preview my php files on my wampserver again.if i try accessing it tru d server,it returns an error message.den if i try to open d file using dreamwaver cs5,it trigger d browser to start downloading d php file repeatedly.i ve try uninstalling nd re-installing d wampserver bt d problem is still dere.any help my pple
try editing the php file with notepad. that should solve the issue
Re: Post your PHP Problems Here by ps3o(m): 1:46pm On Mar 11, 2015
Debeloved87:
how can i shorten posts on the main page of the blog, that viewers will have to view the whole post by clicking "continue reading" ?

<?php
$thepost="the whole as a whole";
$start=0; //0 is the first array position in the php. u can change it to whichever position you would want it to start displaying from the string

$length=70 //depending on the no of strings u want to show from the post

echo substr($thepost,$start,$length);

?>

//constructed by Phemmy THE WEB DEVELOPER 07031175291
Re: Post your PHP Problems Here by Adesege(m): 6:36pm On Mar 11, 2015
Next time, it's advisable u post a sample code where u nid help. We can't work on abstract.

Let's create a php function, so we can use it multiple times in our project.

<?php
function truncate($text, $chars =150, $terminator=' …'){
$cutPos = $chars - mb_strlen($terminator);

$boundaryPos = mb_strrpos(mb_substr($text,0, mb_strpos($text,' ', $cutPos)),' ');

return mb_substr($text,0, $boundaryPos ===false? $cutPos : $boundaryPos). $terminator;

}

?>

By default, the text will be truncated by 150chars and terminated by "...".

You can edit the terminator variable to a link and the chars variable.

Feel free to let me know if u encountered any problem.
.
EDIT::

USUAGE:

truncate($text,"300","..."wink

or

truncate($text,"300","<a href='path/to/page'>some text"wink
Debeloved87:
how can i shorten posts on the main page of the blog, that viewers will have to view the whole post by clicking "continue reading" ?
Re: Post your PHP Problems Here by kobonaire(m): 3:16pm On Mar 12, 2015
I'm reading strings from an XML file, how can I check that the values are integers?
Re: Post your PHP Problems Here by Adelekebalogun: 3:21pm On Mar 12, 2015
GET CHEAP DATA
BUNDLES AT VERY LOW RATE MTN 300GB FOR
3000, AIRTEL 250gb FOR 3000, GLO 300GB FOR
3000, ETISALAT 300GB FOR 3000 call
07062471665 DATA WORKS ON ALL DEVICE BOTH
MOBILE AND PC[color=#006600][/color]
Re: Post your PHP Problems Here by Ilekeh(f): 3:28pm On Mar 12, 2015
Does anyone else use Lynda's PHP tutorials?
Re: Post your PHP Problems Here by gdamola(m): 3:28pm On Mar 12, 2015
See Ojoro..Y will this thread be on Front Page?How does your php problems concern politicians?....Moderators.....Hmmmmmnnnn....Bribe is not good ooooooo.....Abeg no suspend me ooo..I no talk say u collect bribe oooo.....
<?php
echo "BRIBE IS NOT GOOD"
?>
Re: Post your PHP Problems Here by GodMode: 3:30pm On Mar 12, 2015
gdamola:
See Ojoro..Y will this thread be on Front Page?How does your php problems concern politicians?....Moderators.....Hmmmmmnnnn....Bribe is not good ooooooo.....Abeg no suspend me ooo..I no talk say u collect bribe oooo.....
<?php
echo "BRIBE IS NOT GOOD"
?>

UNDEFINED ERROR: missing ; on line 7..
Re: Post your PHP Problems Here by silvernus0: 3:49pm On Mar 12, 2015
hi gurus, i knw how to set up a file image upload textbox to upload image to the database. after d image is uploaded to d database how do i call d image to show on a page e.g photos.php page wen it is viewd on d browser to see d images i uploaded to d db. tnks Gurus.
Re: Post your PHP Problems Here by Adesege(m): 4:00pm On Mar 12, 2015
Please post a sample code.
.
.
But u can cast the string into int using:
.
.
$string=(int)$fetch["string"];
.
Post a sample code
kobonaire:
I'm reading strings from an XML file, how can I check that the values are integers?
Re: Post your PHP Problems Here by JackOfAllTrades: 4:02pm On Mar 12, 2015
GodMode:


UNDEFINED ERROR: missing ; on line 7..
The code will run without errors. It just one line of code semi colon is optional

(1) (2) (3) ... (14) (15) (16) (17) (18) (19) (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.