Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,208,401 members, 8,002,505 topics. Date: Thursday, 14 November 2024 at 12:16 PM

My First Real PHP Based Website - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / My First Real PHP Based Website (8881 Views)

Closed - Out of date / Question And Answer Based Website (Program Routes) (2) (3) (4)

(1) (2) (Reply) (Go Down)

My First Real PHP Based Website by Thirdwrist(m): 10:17pm On Feb 29, 2016
MY FIRST REAL PHP SITE

When you are inspired by some great purpose, some extraordinary project, all of your thoughts break their bonds: your mind transcends limitations, your consciousness expands in every direction and you find yourself in a new, great and wonderful world. Dormant forces, faculties and talents come alive and you discover yourself to be a greater person than you ever dreamed of…… (The monk who sold his Ferari).



One of my plans this year is to build a PHP site for my ex secondary school Alumni and one for the school itself, to someone else it might seem like a walk in the park, but mine isn’t the case, I am very new to the PHP world though I am quite fluent in HTML and CSS and understand the syntax of JavaScript.

This will be a deliberate effort of mine to swim with the sharks, its obvious I will make a lot of mistakes and get frustrated a lot of times, which brings me to the aim of me starting this tread, they are a lot of good programmers over here, on whose shoulder I can lean on, I will post every single code of mine here and regularly update my progress for critique and when I need help.

Tools:
Bootstrap,
Xampp
Sublime.

Thank you all in advance.
Re: My First Real PHP Based Website by ANTONINEUTRON(m): 10:25pm On Feb 29, 2016
Am watching!!!

1 Like

Re: My First Real PHP Based Website by sinkernet: 10:55pm On Mar 01, 2016
If u ever get stuck, I'll be @ your service

1 Like

Re: My First Real PHP Based Website by winar(m): 1:24pm On Mar 04, 2016
Bro, I will advise u go with Dreamweaver.
Re: My First Real PHP Based Website by Thirdwrist(m): 3:33am On May 24, 2016
sinkernet:
If u ever get stuck, I'll be @ your service

How do I rectify this?


public $sql;
public $row;
public $result;
public $something;
public function dbr(){

$this->sql="SELECT username, id FROM users";
foreach ($this->result->exec($sql) as $row) {
print $row['id'] . "\t";
print $row['username'] . "\n";

}



It reply's :

Fatal error: Call to a member function exec() on a non-object in E:\xampp\htdocs\Experiments\gstosa\index1.php on line 34

dhtml18
larisoft
nauman673
hcpaul
guru01
davidthegeek
sonoflucifer
hitz
Adesege
Re: My First Real PHP Based Website by FagsamPHP(m): 4:17am On May 24, 2016
*sips Orijin*
Re: My First Real PHP Based Website by DavidTheGeek: 7:20am On May 24, 2016
Thirdwrist i'm not too familiar with php. Sorry can't help. dhtml18 come o
Re: My First Real PHP Based Website by Booyakasha(f): 7:36am On May 24, 2016
Thirdwrist:

How do I rectify this?

public $sql;
public $row;
public $result;
public $something;
public function dbr(){
$this->sql="SELECT username, id FROM users";
foreach ($this->result->exec($sql) as $row) {
print $row['id'] . "\t";
print $row['username'] . "\n";
}

It reply's :
Fatal error: Call to a member function exec() on a non-object in E:\xampp\htdocs\Experiments\gstosa\index1.php on line 34
dhtml18
larisoft
nauman673
hcpaul
guru01
davidthegeek
sonoflucifer
hitz
Adesege


You won't get quality help here, wait until we finish our community next week smiley

1 Like

Re: My First Real PHP Based Website by Nobody: 7:41am On May 24, 2016
Booyakasha:



You won't get quality help here, wait until we finish our community next week smiley

PLz mrs. what is the name of the community coz i want to join as soon as it comes online.
Re: My First Real PHP Based Website by Booyakasha(f): 7:46am On May 24, 2016
crotonite:

PLz mrs. what is the name of the community coz i wam't to join as soon as it comes online.

alright.. I'll mention you as soon as we launch.. thanks smiley

1 Like

Re: My First Real PHP Based Website by ALLU: 8:25am On May 24, 2016
Booyakasha:



You won't get quality help here, wait until we finish our community next week smiley
How do you know?!
The guys op mentioned have not yet seen his code and you're discrediting them... That's advertising in bad faith o.
@OP... While some of your errors are already obvious you should post the class so we can help comprehensively...
Re: My First Real PHP Based Website by DavidTheGeek: 9:29am On May 24, 2016
Booyakasha:

You won't get quality help here, wait until we finish our community next week smiley

undecided if that were true, you'd have helped him now. Obviously you can't help too.
Re: My First Real PHP Based Website by Thirdwrist(m): 9:30am On May 24, 2016
This is the whole code as requested
Thanks for help in advance, i really appreciate.

ALLU


<?php
class user{
//inniating variables to be used in db_connect method.
// Database assess values.

public $db_host= "localhost";
public $username="";
public $password= "";
public $db_name="php_database";
public $dbc;

// method to connect to database
function connect(){
try{

$this->dbc= new PDO("mysql:host=$this->db_host; dbname=$this->db_name;charset=utf8", $this->username, $this->password);
}
catch (PDOException $e){
echo "failed to connect to database pdo ";
echo $e->getmessage();
exit();
}
return $this->dbc;
}


public $sql;
public $row;
public $result;
public $something;
public function dbr(){

$this->sql="SELECT username, id FROM users";
foreach ($this->result->fetch($sql) as $row) {
print $row['id'] . "\t";
print $row['username'] . "\n";

}

}
}
$usermanagment= new user();
$usermanagment->connect();
echo "you are an OOP genius";
$usermanagment->dbr();
echo $usermanagment->sql;

?>

Re: My First Real PHP Based Website by Booyakasha(f): 10:16am On May 24, 2016
DavidTheGeek:


undecided if that were true, you'd have helped him now. Obviously you can't help too.
I can.. but No! wink
Re: My First Real PHP Based Website by DavidTheGeek: 11:18am On May 24, 2016
Booyakasha:

I can.. but No! wink

I believe i can fly.. Spread my wings and fly away... (remember that song? by R. Kelly...) R. Kelly still walks on foot! grin He hasn't grown wings to fly still... You sound just like him! cheesy angry

5 Likes

Re: My First Real PHP Based Website by sleepingdemon: 12:37pm On May 24, 2016
Op the content of the file you outline is it index1.php?
The class you provided, if ran, would return "you are an oop genius"
the error you are recieving is from the index1.php class, not the class.
besides, i guess you want the file to print out you are an oop genius and also usernames and id gotten from the user table.

if that is the case, ive corrected your class to be like this, and it should work.

But i repeat, the error of exec you are getting is from index1.php, not this file.


<?php
class user{
//inniating variables to be used in db_connect method.
// Database assess values.

public $db_host= "localhost";
public $username="";
public $password= "";
public $db_name="php_database";
public $dbc;
public $sql;
public $row;
public $result;
public $something;

function __construct(){

$this->connect();
}

// method to connect to database
function connect(){
try{

$this->dbc= new PDO("mysql:host=$this->db_host; dbname=$this->db_name;charset=utf8", $this->username, $this->password);
}
catch (PDOException $e){
echo "failed to connect to database pdo ";
echo $e->getmessage();
exit();
}
return $this->dbc;
}




public function dbr(){
$this->sql="SELECT username, id FROM users";

$stmt=$this->dbc->query($this->sql);
return $stmt;
return $stmt->fetchAll(PDO::FETCH_ASSOC);




}
}
$usermanagment= new user();



echo "you are an OOP genius";
echo "<br>";
try {
$answer=$usermanagment->dbr();

foreach ($answer as $row) {
print $row['id'] . "\t";
print $row['username'] . "\n";

}
} catch(PDOException $ex) {
echo $ex->getmessage();
//handle me.
}
echo "<br>";
echo $usermanagment->sql;


?>
Re: My First Real PHP Based Website by Djade007: 12:56pm On May 24, 2016
Nairaland is not designed for codes. You can use School Network. Look at an example here https://schoolnetwork.io/529/c-programming-tutorial
Re: My First Real PHP Based Website by Booyakasha(f): 1:36pm On May 24, 2016
Djade007:
Nairaland is not designed for codes. You can use School Network. Look at an example here https://schoolnetwork.io/529/c-programming-tutorial
You're right but the site you just shared looks weird..
Re: My First Real PHP Based Website by Djade007: 2:40pm On May 24, 2016
Booyakasha:

You're right but the site you just shared looks weird..
weird as how?
Re: My First Real PHP Based Website by Booyakasha(f): 3:10pm On May 24, 2016
Djade007:
weird as how?
design.. it's not really something cool.. nairaland looks better..
Re: My First Real PHP Based Website by Djade007: 3:48pm On May 24, 2016
Ok, probably the desktop view. It looks cool on mobile

Re: My First Real PHP Based Website by Booyakasha(f): 4:48pm On May 24, 2016
Djade007:
Ok, probably the desktop view. It looks cool on mobile
no.. mobile is boring...
Re: My First Real PHP Based Website by Djade007: 5:06pm On May 24, 2016
Booyakasha:
no.. mobile is boring...
I have worked with alot of ui frameworks.
That website was made to be as light as possible, no frameworks were used. However I have started creating a new version with Angular2
Re: My First Real PHP Based Website by Booyakasha(f): 5:43pm On May 24, 2016
Djade007:
I have worked with alot of ui frameworks.
That website was made to be as light as possible, no frameworks were used. However I have started creating a new version with Angular2

Okay cool.. I'll love to see it, btw we're almost done creating our community.. i hope you become a contributor there.. cheesy
Re: My First Real PHP Based Website by AnthonyAk(m): 9:58pm On May 25, 2016
heroku.com + github , that way you caan easily collaborate and ask questions with proper examples
Re: My First Real PHP Based Website by Nobody: 12:59am On May 26, 2016
DavidTheGeek:
Thirdwrist i'm not too familiar with php. Sorry can't help. dhtml18 come o

Who is this one again...
Re: My First Real PHP Based Website by Nobody: 1:03am On May 26, 2016
Booyakasha:



You won't get quality help here, wait until we finish our community next week smiley

After all the stylish advertisement of "your community - Gdevit", it better be top notch when you launch.

2 Likes

Re: My First Real PHP Based Website by Booyakasha(f): 6:18am On May 26, 2016
DanielTheGeek:


After all the stylish advertisement of "your community - Gdevit", it better be top notch when you launch.
We won't disappoint.. wink
Re: My First Real PHP Based Website by Adesege(m): 8:55pm On May 27, 2016
Thirdwrist:


How do I rectify this?


public $sql;
public $row;
public $result;
public $something;
public function dbr(){

$this->sql="SELECT username, id FROM users";
foreach ($this->result->exec($sql) as $row) {
print $row['id'] . "\t";
print $row['username'] . "\n";

}



It reply's :

Fatal error: Call to a member function exec() on a non-object in E:\xampp\htdocs\Experiments\gstosa\index1.php on line 34

dhtml18
larisoft
nauman673
hcpaul
guru01
davidthegeek
sonoflucifer
hitz
Adesege

I'm just seeing this.

If a solution hasn't been proffered, I will go thru the code and give my observations.

Regards
Re: My First Real PHP Based Website by Nobody: 3:16pm On May 28, 2016
Thirdwrist, can you upload your code on http://www.pastebucket.com? Nairaland is cutting off your code, so you can get help. I can't even see some of your code.
Re: My First Real PHP Based Website by Thirdwrist(m): 1:42am On Jun 03, 2016
I am trying to login to my site with facebook, but it isnt communicating with the database. After login it does not store the user details in the table i created.

CREATE TABLE users(
uid int auto_increment not null primary key,
Fuid not null int,
Ffname varchar(100) not null,
flname varchar(100) not null,
Femail varchar(100) not null

) DEFAULT CHARACTER SET utf8 ENGINE=InnoDB


I got the codes from here
http://www.krizna.com/demo/login-with-facebook-using-php/dhtml18
larisoft
nauman673
hcpaul
guru01
davidthegeek
sonoflucifer
hitz
Adesege

(1) (2) (Reply)

Which Programming Language Holds Brighter Prospects In Nigeria / Data Science Or Cyber Security? / Can Developers Do Without The Use Of Google Or Stackoverflow?

(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. 42
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.