Jump to content

Linked Pages?!


Kylo

Recommended Posts

I have been doing a lot of google searching and such but still havent be able to come up with anything to help me with what I need, and I finally found this site and decided I will post to see if anybody can help. I am currently trying to code my clan site (best viewed in IE, Firefox hates me), and I am trying to find a way to make information update itself on multiple pages by only changing it on one. I know this can be done, cause I have seen it mentioned, but never seen any code. I dont know php or how to make or code a database. So all the more help, the better I can understand to help someone else if needed.

Alright, my test site is www.nwn2world.com/Veneratio2

The information I want to update on all pages is the "Latest Demos", "Latest Matches" and "Veneratio Misc." Boxes. (Again, please view in IE for best results atm) Thank you.
Link to comment
Share on other sites

What I wana do is make it so if I changed the "Latest Demos" section on the index.html it will automatically change the other .html pages like roster.html, sponsors.html and so forth. This way I dont have to manually edit each page by itself.
Link to comment
Share on other sites

well, I have created a database and a table within the db called demos.... trying to get this code to work in my .html page now... I tried this...


<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("nwn2wor_veneratio",$db);
$result = mysql_query("SELECT * FROM `demos` WHERE 1`demo1``demo2``demo3``demo4``demo5`",$db);
echo "<TABLE>";
while($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["demo1"];
echo "<TR><TD>";
echo $myrow["demo2"];
echo "<TR><TD>";
echo $myrow["demo3"];
echo "<TR><TD>";
echo $myrow["demo4"];
echo "<TR><TD>";
echo $myrow["demo5"];
}
echo "</TABLE>";
?>
Link to comment
Share on other sites

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/nwn2wor/public_html/Veneratio2/index.php on line 113

this is what I got back, but if I am going to have to put in my user and password... cant someone steal that?
Link to comment
Share on other sites

alright... I am trying this but getting a parse error...
[code]
<?php
$db = mysql_connect("localhost", "******", "********");
mysql_select_db("nwn2wor_veneratio",$db);
$result = mysql_query("SELECT * FROM `demos`",$db);
or die("Query failed: $sql<br />".mysql_error());
if(!mysql_num_rows($result))
  {
  echo "No results returned by query $sql";
  }
else
  {
"<TABLE>";
while($myrow = mysql_fetch_array($result))
{
"<TR><TD>";
$myrow["demo1"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo2"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo3"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo4"];
"</TR></TD>";
"<TR><TD>";
$myrow["demo5"];
"</TR></TD>";
}
"</TABLE>";
?>
[/code]

also... cant someone just view source and see the login/password?

mod edit  : security data removed and code tags added
Link to comment
Share on other sites

Ok this should work for you.

[code]
<?php

$db = mysql_connect("localhost", "******", "******");
mysql_select_db("nwn2wor_veneratio",$db);
$result = mysql_query("SELECT * FROM `demos`",$db) or die("Query failed: $sql".mysql_error());

if(!mysql_num_rows($result))
echo "No results returned by query $sql";
else
{
echo '
<TABLE>';

while($myrow = mysql_fetch_assoc($result))
{
echo '
<TR>
<TD>', $myrow["demo1"], '</TD>
<TD>', $myrow["demo2"], '</TD>
<TD>', $myrow["demo3"], '</TD>
<TD>', $myrow["demo4"], '</TD>
<TD>', $myrow["demo5"], '</TD>
</TR>';
}

echo '
</TABLE>';
}
mysql_free_result($result);
?>
[/code]
Link to comment
Share on other sites

ahhh, its all good, I delete that db user and created a new one with new password.

I got the code to work by tweaking the table to this..

{
echo '
<TR>
<TD>', $myrow["demo1"], '</TD></TR>
<TR>
<TD>', $myrow["demo2"], '</TD></TR>
<TR>
<TD>', $myrow["demo3"], '</TD></TR>
<TR>
<TD>', $myrow["demo4"], '</TD></TR>
<TR>
<TD>', $myrow["demo5"], '</TD></TR>
</TR>';
}


and now the it looks perfect on my site, thank you.
Link to comment
Share on other sites

Store

[code]
<?php
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("nwn2wor_veneratio",$db);
?>

[/code]

in a file called, say, "connect.inc.php" and store that on the server outside the web root directory tree.

In you scripts that need to acces the db

[code]
<?php
include 'connect.inc.php';
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.