Follow us on Twitter!
You cannot teach a man anything; you can only help him find it within himself. - Galileo
Thursday, April 17, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 24
Guests Online: 23
Members Online: 1

Registered Members: 82815
Newest Member: medjiking
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Page 1 of 3 1 2 3 >
Author

mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 10:10
I know I'm going to get flamed for this, but what the heck I like spyware anyway ^^

I've just started learning mysql & php and as a first impression I might say that things seems rather easy to understand, yet when I try to connect to my MySQL server using php, nothing happens O.o

I'm using one.com as host

Code

<?php
mysql_connect("dbadmin.one.com", "username goes here", "password goes here") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("database goes here") or die(mysql_error());
echo "Connected to Database";
?>





what the heck am I doing wrong? x_x

edit: dbadmin.one.com --> is the MyPhpAdmin address, there is no other address to connect to, so... where do I go from here? :P




Edited by Demons Halo on 20-07-09 10:16
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 10:18
MoshBat wrote:
For starters, "localhost".


come on.. how stupid am I :'( ofc it's localhost since the freaking file is already on the host server -__________-

anyway keep tune, more stupid questions will show up eventually Pfft

thnx pikabat (L)


base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 10:35
MoshBat wrote:
No.
No.
Rather than "blah.one.com", "localhost".
And let me take another look at that script.


ah I got that, stupid noob mistake by me not to put localhost from the start

Code

<?php
mysql_connect("localhost", "username", "pass") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("demonshalo_com") or die(mysql_error());
echo "Connected to Database";

$query = "SELECT * FROM test"
$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['id']. " - ". $row['testare'];

?>





in MyPhpAdmin I've created a table called test with 2 fields (id, testare). So far I can connect and select a database, but I can't seem to show the content of the table. :/

edit: I'm probably going to get pawned for posting the code here...




Edited by Demons Halo on 20-07-09 10:37
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 10:44
awesome, I got it working as well but I hate how you guys make the code seem so clean and professional -_-

$row = mysql_fetch_array($result) or die(mysql_error());

the little "or die(mysql_error())" messed everything up, once I removed it everything worked.

hmm a while loop to print out all the rows =O nice! thnx =D

edit: I'm not here to copy/paste... I'm hear to learn from you holy one! *_'




Edited by Demons Halo on 20-07-09 10:46
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 10:53
as long as I understand the concept I don't care if you color or use black text & black background -_- what idea? O.o

haha that's some "sexy" code right there... NOT

"EDIT#2: Whilst we're here, and I'm bored, any more PHP issues?"

they will eventually pop-up Pfft If you've got some advice for a beginner don't hesitate to post them xD






Edited by Demons Halo on 20-07-09 10:55
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 11:39
MoshBat wrote:
Demons Halo wrote:
If you've got some advice for a beginner don't hesitate to post them xD

Don't be scared to post your problems.
I was nice, was I not?
Also, you can contact me in any way you wish, (except perhaps sending your problem via traditional mail, written in your own faeces) and I'll be more than happy to help you.


you're always nice =D and just for the record: I like getting flamed XD
haha thnx a lot, I really appreciate it.

I have a security question though. A lot of the exploits/hacks done on the web are SQL based, how do I avoid those security issues?




Edited by Demons Halo on 20-07-09 11:41
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 12:29
I'll check that out asap!

here is my first project using php/mysql:
I'm going to build a photo gallery using a table with the fields: id, picture, comment and date.

correct me if I'm wrong but this is how a table should look like:
Code

--------------------------------------------------
| id   |  picture         | comment        |    date      |
--------------------------------------------------
| 1   | images/lal.jpg  | rofl lmao wtf?  | CURDATE() |
---------------------------------------------------





now using php I should do something like:
Code

$result = mysql_query("SELECT * FROM gallery");

while($row = mysql_fetch_array($result)){
   $picture= $row['picture'];
   $comment = $row['comment'];
   $date = $row['date'];
   print "<img src=$picture>-  comment: $comment  -  date: $date <br />";
}





This doesn't work, so I need to know how to load an image to the browser using php. I've found a lot using google, but unfortunately the shortest code I could understand was half a page long -_- is there any easy way to do this?


Edit: I got it working. Minor problem with the quote marks xD






Edited by Demons Halo on 20-07-09 12:51
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 20-07-09 13:43
MoshBat wrote:
Demons Halo wrote:
I'll check that out asap!

here is my first project using php/mysql:
I'm going to build a photo gallery using a table with the fields: id, picture, comment and date.

correct me if I'm wrong but this is how a table should look like:
Code

--------------------------------------------------
| id   |  picture         | comment        |    date      |
--------------------------------------------------
| 1   | images/lal.jpg  | rofl lmao wtf?  | CURDATE() |
---------------------------------------------------





now using php I should do something like:
Code

$result = mysql_query("SELECT * FROM gallery");

while($row = mysql_fetch_array($result)){
   $picture= $row['picture'];
   $comment = $row['comment'];
   $date = $row['date'];
   print "<img src=$picture>-  comment: $comment  -  date: $date <br />";
}





Edit: I got it working. Minor problem with the quote marks xD


For the benefit of those who may suffer similar problems:
Code

$result = mysql_query("SELECT * FROM gallery ORDER BY id ASC");

while($row = mysql_fetch_array($result)){
   $picture= $row['picture'];
   $comment = $row['comment'];
   $date = $row['date'];
   print "<img src='$picture' /> -  comment: $comment  -  date: $date<br />";
}




Note the added apostrophes ('), and the / in the img tag :)
If memory serves, not closing the img tag can cause fuckups in IE6.


Self-closing tags are needed for XHTML, however they aren't for standard HTML, so it won't cause fuckups in IE6.

Also, use "echo" instead of "print", it's faster.


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php

spyware
Member



Posts: 4192
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 20-07-09 13:53
MoshBat wrote:
At his level, mere milliseconds don't really matter.


It doesn't matter whether it matters now. It could matter in the future.

Suboptimal programming is stupid.



img507.imageshack.us/img507/3580/spynewsig3il1.png
"The chowner of property." - Zeph
[small]
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
[/s
http://bitsofspy.net
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 14:11
emm print returns boolean as well right? while echo just "writes" stuff Pfft

edit: another question:
what alternatives are there for loading a page inside of another page? php include / Iframe / jQuery are the ones I know of, any other methods?

using php includes would make the entire site reload, which I actually don't mind, but I'm just wondering what the best method is Pfft




Edited by Demons Halo on 20-07-09 14:27
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

spyware
Member



Posts: 4192
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 20-07-09 14:38
Demons Halo wrote:
I'm just wondering what the best method is Pfft


Depends what you want to use it for/how you want to use it.



img507.imageshack.us/img507/3580/spynewsig3il1.png
"The chowner of property." - Zeph
[small]
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
[/s
http://bitsofspy.net
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 14:45
spyware wrote:
Demons Halo wrote:
I'm just wondering what the best method is :P


Depends what you want to use it for/how you want to use it.


currently i use the following in index.php:
Code

<body>
   <div id="Main" align="center">
      <div id="top">
         <?php include 'top.php'; ?>
      </div>
      <div id="Body" align="left">
         <iframe align="left" id="Iframe" name="Iframe" src="home.php" width="100%" height="100%" style="background-color:transparent; border:none;" scrolling="yes">
         </iframe>
      </div>
   </div>
</body>





I want to get rid of the Iframe by using another method like php include. The idea is when a user clicks on a button (inside top.php), the "body div" in the index.php should change and show the content of a new page depending on what button the user clicks.


base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-07-09 16:30
Code

<?php
$page = $_GET['page'];
?>
<body>
  <div id="Main" align="center">
     <div id="top">
       <?php include 'top.php'; ?>
     </div>
     <div id="Body" align="left">
      <?php include $page; ?>
     </div>
  </div>
</body>





The links within top.php should be like
Code

<a href="index.php?page=lol.php">lol</a>




Obviously, you wil ned security measures :P


Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-07-09 16:30
pm me if you need anymore help


Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-07-09 16:41
quick question Demons Halo, is one.com a good host...i was going to go for it but i was unsure. it seems pretty good but i thought there would be a catch somewhere. cheers


Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 17:12
christian879 wrote:
Code

<?php
$page = $_GET['page'];
?>
<body>
  <div id="Main" align="center">
     <div id="top">
       <?php include 'top.php'; ?>
     </div>
     <div id="Body" align="left">
      <?php include $page; ?>
     </div>
  </div>
</body>





The links within top.php should be like
Code

<a href="index.php?page=lol.php">lol</a>




Obviously, you wil ned security measures :P


ahaaaaaa so that's how the ?page... works, this is indeed handy. What security measures do you have in mind? I'm still a noob remember xD I can't work with complicated 14 page script stuff (yet).


quick question Demons Halo, is one.com a good host...i was going to go for it but i was unsure. it seems pretty good but i thought there would be a catch somewhere. cheers


Yes they are.

+
24/7 support
cheap registration
100% secure when it comes to credit card number etc.
Easy access MySQL DB + latest version of PHP
3000MB for 1.25€ / month --> lol?
Lots of features for admins using IE
Google Adwords coupon

-
No CGI support.

Note:
pretty decent connection.

Total: 9/10 so go for it ;)





Edited by Demons Halo on 20-07-09 17:16
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php

ranma
Member



Posts: 273
Location: Behind a sphere
Joined: 27.08.05
Rank:
Active User
Posted on 20-07-09 18:24
And here I thought DH was some quite experienced guy Pfft

I would suggest GoDaddy hosting. Their customer service is AMAZING and they have tons and tons of features.


Wisdom spared is wisdom squared.
Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 20-07-09 18:32
ranma wrote:
And here I thought DH was some quite experienced guy

You best be jokin, nigga! Pfft

Demons Halo wrote:
ahaaaaaa so that's how the ?page... works

Please man, for the love of chocolate, look into some basic http before you delve into PHP. You don't hate chocolate... do you? Shock


Author

RE: mysql/php

ranma
Member



Posts: 273
Location: Behind a sphere
Joined: 27.08.05
Rank:
Active User
Posted on 20-07-09 18:39
But seriously, some of those question could have been easily answered by looking at w3schools's php/mysql tutorials.


Wisdom spared is wisdom squared.
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 20-07-09 18:49
COM wrote:
ranma wrote:
And here I thought DH was some quite experienced guy

You best be jokin, nigga! Pfft

Demons Halo wrote:
ahaaaaaa so that's how the ?page... works

Please man, for the love of chocolate, look into some basic http before you delve into PHP. You don't hate chocolate... do you? Shock


HEY HEY HEY!!!!
hey I'm a noob I admit that much Pfft and thnx for believing in my hidden power ranma! (L)

haha I love chocolate, I even married it once!
Just to be 100% clear... I HATE BUILDING WEBB BASED PROGRAMMING. I joined this community so that I could learn a bit about computer languages (and thnx to ynouri7 I started with python).
yesterday I got bored so I thought that maybe it's time to start with something else like PHP/MySQL Pfft and so fast everything seems easy and fun =D

and yes ranma W3school is great, although I'm googling most of the questions I've got. Having stuff explained on the spot is so much better than reading through 16 pages just so that you notice the FREAKING ; you need to put at the end of each line -_-




Edited by Demons Halo on 20-07-09 18:51
base_dropper@hotmail.com www.demonshalo.com
Page 1 of 3 1 2 3 >