Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-16-2013, 10:20 PM   PM User | #1
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
Passing PHP variables into html tags

I have a php script that gets a string from my MySQL database and puts certain elements into variables.

PHP Code:
<?php
$connection 
mysqli_connect('database','user','pw','the_sleeper');
$audiopath mysqli_query($connection,"select * from the_sleeper");
$row mysqli_fetch_array($audiopath);
$audio=$row['audiopath'];
$title$row['title'];
?>
Now I want these two variables on to my main page. I want the audiopath to be passed to an audio embed tag and title to be passed into a heading tag. How can I do this?
Here is the link to the page I will be passing them to:http://www.j10thesleeper.net84.net/J...rhomepage.html
Thank you all for your time!

Last edited by torsaur; 03-16-2013 at 10:33 PM..
torsaur is offline   Reply With Quote
Old 03-16-2013, 10:40 PM   PM User | #2
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
PHP Code:
<audio controls>
  <source src="<?php echo $audio?>" type="audio/mpeg"/>
</audio>
Code:
<h2> <?php echo $title; ?></h2>
Do you mean this?
tempz is offline   Reply With Quote
Old 03-16-2013, 10:56 PM   PM User | #3
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
First I need to call the php file itself. I have the file stored so I want to link it in and have it run without putting the code itself directly on the html page.
torsaur is offline   Reply With Quote
Old 03-17-2013, 12:33 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,600
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
That’s not possible, you have to somehow insert PHP code into your current HTML page, otherwise the page wouldn’t know what to display.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 03-17-2013, 02:25 AM   PM User | #5
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
Isn't it a security concern to have my MySQL database, username, and password out there for everyone to see?
torsaur is offline   Reply With Quote
Old 03-17-2013, 02:52 AM   PM User | #6
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
Quote:
Originally Posted by torsaur View Post
Isn't it a security concern to have my MySQL database, username, and password out there for everyone to see?
The file is .php it can't be read by going to the url www.example.com/connect.php
tempz is offline   Reply With Quote
Old 03-17-2013, 08:49 PM   PM User | #7
torsaur
New Coder

 
Join Date: Mar 2013
Location: Kentucky
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
torsaur is an unknown quantity at this point
Thank you all! I didn't realize that if you coded php directly onto a page it couldn't be seen through view source!
torsaur is offline   Reply With Quote
Old 03-17-2013, 11:27 PM   PM User | #8
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
Quote:
Originally Posted by torsaur View Post
Thank you all! I didn't realize that if you coded php directly onto a page it couldn't be seen through view source!
You must make sure the extension is dot php else users can view php code because it will display as text.
tempz is offline   Reply With Quote
Reply

Bookmarks

Tags
html, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:01 AM.


Advertisement
Log in to turn off these ads.