Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-15-2011, 03:42 PM Mysql link issue...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Hi,

I have a column in my database to store a url, but the url is not quite the standard url, it's in a form such as this:

Code:
$f = fopen('http://reunitemysite.com/scripts/amp/show.php?z=1&incl=1&ip='.getenv('REMOTE_ADDR').'&url='.urlencode(getenv('HTTP_HOST').getenv('REQUEST_URI')),'r');
echo stripslashes(fread($f,100000));
fclose($f);
Could I store that url in the database and will it still work? I have tried it unsuccessfully. I don't mean just the http part either, because that is the exact code generated for the page to output certain data from another script on my site. I also have the option to use javascript like:

Code:
<script type="text/javascript"><!--
document.write('<s'+'cript type="text/javascript" src="http://reunitemysite.com/scripts/amp/show.php?z=1&j=1&code='+new Date().getTime()+'"></s'+'cript>'); 
// --></script>
<noscript>
<iframe src="http://reunitemysite.com/scripts/amp/show.php?z=1" width="120" height="240" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
</noscript>
I prefer to use the first code though, not the javascript one.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-15-2011, 04:39 PM Re: Mysql link issue...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can't read PHP from a database using PHP and expect it to run because it won't.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-15-2011, 06:27 PM Re: Mysql link issue...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by chrishirst View Post
You can't read PHP from a database using PHP and expect it to run because it won't.
Then how could I put data (or that url) on a page where the urls are dynamic? Such as category.php?id=1 (data will be on the id=1 page)
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 07-15-2011, 11:13 PM Re: Mysql link issue...
AdsMakeSense's Avatar
Junior Talker

Posts: 3
Trades: 0
What type of database are you trying to insert into? mySQL?
What format is the URL in?
If it's mySQL, should be as easy as cleaning the input URL and inserting it into the database.
AdsMakeSense is offline
Reply With Quote
View Public Profile
 
Old 07-16-2011, 03:40 AM Re: Mysql link issue...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by AdsMakeSense View Post
What type of database are you trying to insert into? mySQL?
What format is the URL in?
If it's mySQL, should be as easy as cleaning the input URL and inserting it into the database.
1. MySQL
2. PHP or Javascript (I posted both forms in the post above)
3. I don't understand what you mean by cleaning the input URL.

Thank you
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 07-16-2011, 09:24 AM Re: Mysql link issue...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Brian07002 View Post
Then how could I put data (or that url) on a page where the urls are dynamic? Such as category.php?id=1 (data will be on the id=1 page)
The PHP code in the format you posted would have to run BEFORE being stored in the database and the resulting OUTPUT then stored in the DB so it can simply be written to the requesting user agent as a text/html data stream.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-16-2011, 01:43 PM Re: Mysql link issue...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by chrishirst View Post
The PHP code in the format you posted would have to run BEFORE being stored in the database and the resulting OUTPUT then stored in the DB so it can simply be written to the requesting user agent as a text/html data stream.
Could you give an example Chris? Sorry to be so helpless, but I've been so busy with other things lately, is crazy. I would call this index a major project for me, but without the help of you guys, I don't know where i'd be.

Thanks again!
-Brian
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 07-16-2011, 07:12 PM Re: Mysql link issue...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Ok, I am going to show the entire working script that I am using for my category index page. What I am trying to figure out now (an it's the last thing, I promise) is how to display a dynamic page for ad zone. Let me give you an example of the zone (url) first:

Zone URL:
PHP Code:
$f fopen('http://reunitemysite.com/scripts/amp/show.php?z=3&incl=1&ip='.getenv('REMOTE_ADDR').'&url='.urlencode(getenv('HTTP_HOST').getenv('REQUEST_URI')),'r');
echo 
stripslashes(fread($f,100000));
fclose($f); 
Now the category index page is:

PHP Code:
<html>
<head><title>Reunite My Site - Category Index</title>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta name="Description" content="The World's Most Trusted Source For Online Advertising!">

<style type="text/css">

html {
height: 100%;
width: 100%;
}

body {
border: 0px solid #000;
height: 100%;
width: 100%;
margin: 0px auto;
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
color: #000;
}

.gradient {
border: 1px solid #000;
background: #c5deea; /* old browsers */
background: -moz-linear-gradient(top, #c5deea 0%, #8abbd7 31%, #066dab 100%) fixed no-repeat; /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c5deea), color-stop(31%,#8abbd7), color-stop(100%,#066dab)) fixed; /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c5deea', endColorstr='#066dab',GradientType=0 ); /* ie */
margin: 0px auto;



/* Links Section  */

a:link {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}

a:visited {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}

a:hover {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}
  
a:active {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}

</style>


<body>

<div class="gradient">

<!-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<!--                                                                C A T E G O R Y      I N D E X      T E M P L A T E                                               -->
<!-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------->

<?php 

// Create Conection To MySQL DB

$db_link mysql_connect("localhost""user""pass");
$db_name mysql_select_db("db");

// Build Query To Subcategory ID

if ( isset($_GET['id']) && is_numeric($_GET['id'] )) {

$cat_id $_GET['id'];
$subcats_query_sql "SELECT * FROM categories, subcategories WHERE categories.category_id = $cat_id AND categories.category_id = subcategories.subcategory_cat_id";
$subcats_query mysql_query($subcats_query_sql);

// Outputs you a list of subcategories in this category

echo "<div align=\"center\"> <h3> Subcategory Index </h3></div>";

echo 
"<ul>";
while (
$row mysql_fetch_array($subcats_query) ) echo "<li>{$row['subcategory_name']}";
echo 
"</ul>";

} else {

echo 
"<div align=\"center\"> <h3> Category Index </h3></div>";

$cat_query_sql "SELECT * FROM categories";
$cat_query mysql_query($cat_query_sql); 


$cols=6;        // Here we define the number of columns
echo "<div align=\"center\"> <table>";    // The container table with $cols columns
do{
echo 
"<tr>";
for(
$i=1;$i<=$cols;$i++) {    
    
// All the rows will have $cols columns even if the records are less than $cols

$row=mysql_fetch_array($cat_query);
if(
$row){
// $img = $row['image_path'];
?>

<td>
<table>
<tr valign="top">
<!-- <td><img src="http://tycoontalk.freelancer.com/images/<?=$img ?>" /></td> <!-- columns can have both text and images -->
<td>
    
<!-- This is the categories list in column form -->

<?php echo "<a href=\"categories.php?id={$row['category_id']}\">{$row['category_name']}</a>";?>
<?php $row
['email'?><br />
<?php $row['password'?><br />
</td>
<td width="50">&nbsp;</td>    <!-- Create gap between columns -->
</tr>
</table>
</td>

<?php
}
else{
echo 
"<td>&nbsp;</td>";    //If there are no more records at the end, add a blank column
}
}

while(
$row);
echo 
"</table>";

// This is the categories list in list form

//echo "<ul>";
//while ( $row = mysql_fetch_array($cat_query) ) echo "<li><a href=\"categories.php?id={$row['category_id']}\">{$row['category_name']}</a></li>";
//echo "</ul>";


?>
</div>
</body>
</html>
:::: NOTE :::: I have progressed some more with this project, but I am still need a push with this next step, or at least another resource online, with a good example of what I am trying to do.

What I would like to have happen is when a category linked is clicked, it shows the subcategories (and yes, all categories WILL contain subcategories) then from the subcategory page, the subcategories will be a linked to a zone url (as I posted in this message, but how??) . Since the above zone (url) code cannot be used in mysql as Chrishirst says, I know I would have to echo out part of the url in the php page, and the other part from mysql, correct? Could someone get me going on that? I feel so stumped, I am naturally good learner by example.

Thank you so much!
-Brian
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 07-17-2011 at 12:28 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 07-17-2011, 02:27 AM Re: Mysql link issue...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Ok, here seems to be the final issue. I can't figure out the best way for this situation. I want to link the subcategories to a dynamic page, one that is not stored on the server, but instead from the mysql db. Does this page need to be a new row in the database called output or something? Or should I create a new page altogether, and link to that some how? The end result: I do NOT want to have to create a new page for each subcategory in the index.
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 07-17-2011 at 03:00 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Mysql link issue...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49838 seconds with 12 queries