View Full Version : REQ: MySQL in PHP
Surreal
July 1st, 2010, 18:03
Fixed, thanks for all your help.
There was just a little mistake that I did :(
Matt`
July 1st, 2010, 22:25
I'd happily have a go at fixing it for you if you indented your code and made it a little easier to read and understand. That's just crazy..
Surreal
July 1st, 2010, 22:27
Haha, sorry bout that. I would fix it up indent it for you but I really don't have time, do you think you can fix it?
Edit: I sort of fixed up the view.php although there isn't much to be indented...
Matt`
July 1st, 2010, 22:32
Not really, because it's still really confusing, especially to someone who barely has any idea of what you're trying to do in the first place.
Protips:
- Don't open and close php tags just to echo stuff. Not only does it make your code look bad and cause structure issues later on, but it makes your site slower
- Don't use caps for html tags. It's unconventional and looks horrible
- Indent everything that is a child of something. That includes while/if statements, html tags etc etc.
Surreal
July 1st, 2010, 22:48
May you please just fix the problem with my script?
Justin H
July 2nd, 2010, 00:50
This should fix the problem:
<html>
<?php
mysql_connect("localhost", "Nick", "******");
mysql_select_db("blab");
$result = mysql_query("SELECT * FROM user WHERE id='$id'");
while ($myrow = mysql_fetch_assoc($result))
{
echo "Server Name: ".$myrow["server"];
echo "<br>IP: ".$myrow["ip"];
echo "<br>Port: ".$myrow["port"];
echo "<br>Details: ".$myrow["details"];
}
?>
</html>
Surreal
July 2nd, 2010, 11:30
That's for your reply, I uploaded an tested but sadly nothing at all loads.
Example: Only the registered members can see the link.
Matt`
July 2nd, 2010, 13:27
I can't see where $id is set.
Daedalus
July 2nd, 2010, 13:39
Well i don't see where you set $id; so if you ain't set it set as $id = $_GET["id"];
Obviously put before the MySQL query.
Another thing, add this to your query after the mysql_fetch_array.
if (mysql_num_rows($result) == 0){echo "Unable to retrieve data.";}
That way we know if it is retrieving data or not.
TehCow
July 2nd, 2010, 14:00
And Nick, lookin forward to make the RSPS Community Runesource?
This would help a bit to.
my pker pure
July 2nd, 2010, 14:52
Looks good, mind if i use it?
Justin H
July 2nd, 2010, 21:33
Oh yes, $id isn't set. So you should have a if statement to always check if $id is set, as important as it is.
Surreal
July 4th, 2010, 04:10
Looks good, mind if i use it?
I would prefer if you didn't.
Thanks.
Toonshorty
July 4th, 2010, 11:30
Locked.
Problem solved.
Powered by vBulletin® Version 4.1.9 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.