Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Dynamic Pages [PHP] & [MySQL]

Newbie Spellweaver
Joined
Aug 11, 2014
Messages
7
Reaction score
0
Dynamic Pages [PHP] & [MySQL]

Hello!

I need to guidess, i started recently with thinking about starting with PHP. I had a fun idea what i wanted to do.

So i had a basic idea, to create some info about someone or something ill use as a example a person. I wanted to register the info into a database (What is actually working).

And then i did want to display the info of 1 registered object like.
Code:
ID = AI
FirstName
LastName
Gender
Adddate

So i did a little research on how i wanted to do that and i believe its called dynamic pages?:mellow:
So i found but its focussed on showing comments what might be fun later on.

Im kinda stuck now and might need to adjust the way im learning or trying to learn atleast.
What im doing now is lookup work mostly copy it make it work and then see if i can understand whats going on.

Can someone give me a direction where i can find something like this?

(The Full idea is where i have a search bar that will accept ID's for now and brings me to the right page with the information i wanted. Later i want to change the search function from ID to a Firstname.)



Not sure how to post if i've got an update so for now ill add a comment.

I found Dynamic urls where some people were saying how to use it so i tryed

PHP:
<?phpinclude 'configs/mysql_connect.php'$id = (int)$_GET['id'];$sql = "select * from users where id = $id";$result = mysql_query($sql, $conn);
if ($result){    $row = mysql_fetch_row($result);    $title = $row[0];    $content = $row[1];    }?>
<html>    <head>    <title><?php echo $title ?></title>    </head>    <body>        <h1><?php echo $title ?></h1>        <p><?php echo $content ?></p>    </body></html>

And im getting
Code:
[COLOR=#000000][B]Parse error: syntax error, unexpected '$id' (T_VARIABLE) in C:\wamp\www\index.php on line [/B][/COLOR][I]3[/I]
 
Last edited:

x42

Skilled Illusionist
Joined
Dec 26, 2008
Messages
388
Reaction score
80
Hey

Have a look at some courses from codeacademy ( , ).

JavaScript / node.js is popular now for doing this kind of things and its more fun than PHP (in my opinion). is easy and you learn a lot about web development with js + node there.
 
Junior Spellweaver
Joined
May 21, 2011
Messages
154
Reaction score
47
You forgot a semicolon right here
Code:
mysql_connect.php'[b];[/b]$id = (int)

EDIT:

I wouldn't recommend to use mysql_* functions. Because they're insecure and deprecated ( has also been removed in PHP7). Use instead!
 
Newbie Spellweaver
Joined
Aug 11, 2014
Messages
7
Reaction score
0
Thanks! I did not see that :$:, Seems like the mysql_query also gives an error, ill try to replace it with PDO!

After trying some things i finally seemed to get the hang of it, in the process i finally began to understand it lol..

People who are curious how it looks here it is maybe it helps someone out, also any feedback if i did it right? or can add somethings to make it more secure etc.


mysql_connectpdo.php
Code:
<?php
// Create connection
$conn = new PDO('mysql:host=LOCALHOST;dbname=DBNAME', 'USER', 'PASSWORD');
// Check connection, Still looking for this hehe.

?>


index.php
Code:
<?phpinclude 'configs/mysql_connectpdo.php';
$id = (int)$_GET['id'];
$result = $conn->query("SELECT * FROM users WHERE id = $id");


if ($result){
    $row = $result->fetch(PDO::FETCH_NUM);
    $id = $row[0];
    $FirstName = $row[1];
    $LastName = $row[2];
    $Email = $row[3];
    $PhoneNumber = $row[4];
    }
?>


<html>
    <head>
    <title>Retrieving Data</title>
    </head>
    <body>
        <p><?php echo $FirstName?><br>
        <?php echo $LastName?><br>
        <?php echo $Email?><br>
        <?php echo $PhoneNumber?><br>
    </body>
</html>


Untitled - Dynamic Pages [PHP] & [MySQL] - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Last edited:
Back
Top