Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page Need help to fix my code
Reply

 

Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
nivram2880@yahoo.com is on a distinguished road
 
Posts: 6
Join Date: Jul 2008
Default Need help to fix my code - 07-17-2008, 03:19 AM

I just want to know if theres something error with my code.. i need to view individual record from my database MySql... when i look in to ineternet there has no error shown in homepage but it shown nothing mean while my home page is empty...click here and below is my code:

nivram2880@yahoo.com

Thank You


<?
$DB_USER="a2156109_123";
$DB_PASS="12345678";
$DB_NAME="a2156109_ddb";
$DB_SERVER="mysql1.000webhost.com";

mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);
@mysql_select_db($DB_NAME) or die( "Unable to select database");
$query="SELECT * FROM users WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"title");
$last=mysql_result($result,$i,"autor");
$phone=mysql_result($result,$i,"artist");

?>
Reply With Quote
(#2 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 354
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 07-17-2008, 04:17 AM

you have to give $id a value. I guess the id is traveling in the url so just add $id = $_GET["id"];

Last edited by Red-X : 07-17-2008 at 04:19 AM.
Reply With Quote
(#3 (permalink))
Old
Junior Member
nivram2880@yahoo.com is on a distinguished road
 
Posts: 6
Join Date: Jul 2008
Default 07-17-2008, 05:44 AM

Actually that was my previous code in my old site and it works so well.. is there something code that requied to put or what ever to configure in phpmyadmin?
Reply With Quote
(#4 (permalink))
Old
Junior Member
nivram2880@yahoo.com is on a distinguished road
 
Posts: 6
Join Date: Jul 2008
Default 07-17-2008, 05:49 AM

here is the url named iframe.php the text that show there are from database it will shown and there has a link to get there record.
Reply With Quote
(#5 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 354
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 07-17-2008, 05:55 AM

Quote:
Actually that was my previous code in my old site and it works so well
So where is the new code? Can you post it?
Reply With Quote
(#6 (permalink))
Old
Junior Member
nivram2880@yahoo.com is on a distinguished road
 
Posts: 6
Join Date: Jul 2008
Default 07-17-2008, 06:49 AM

Here is the new code same as aboveand same as of my old code i've only changes the info of this:

$DB_USER="a2156109_123";
$DB_PASS="12345678";
$DB_NAME="a2156109_ddb";
$DB_SERVER="mysql1.000webhost.com";


<?
$DB_USER="a2156109_123";
$DB_PASS="12345678";
$DB_NAME="a2156109_ddb";
$DB_SERVER="mysql1.000webhost.com";

mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);
@mysql_select_db($DB_NAME) or die( "Unable to select database");
$query="SELECT * FROM users WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"title");
$last=mysql_result($result,$i,"autor");
$phone=mysql_result($result,$i,"artist");

?>
Reply With Quote
(#7 (permalink))
Old
Bad Karma[CORE]'s Avatar
Senior Member
Bad Karma[CORE] is on a distinguished road
 
Posts: 274
Join Date: May 2008
Send a message via ICQ to Bad Karma[CORE] Send a message via AIM to Bad Karma[CORE] Send a message via MSN to Bad Karma[CORE] Send a message via Yahoo to Bad Karma[CORE] Send a message via Skype™ to Bad Karma[CORE]
Default 07-17-2008, 07:39 AM

i might have eyes as sharp as a gopher, but where is $id defined, respectively where does it get its value from ?


(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
While Bunny is doing that you might as well visit my Blog
5 Bucks Script Installation Services
Free Web Hosting
Reply With Quote
(#8 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 354
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 07-17-2008, 04:34 PM

Quote:
Originally Posted by Bad Karma[CORE] View Post
i might have eyes as sharp as a gopher, but where is $id defined, respectively where does it get its value from ?
Right, I have the same question here.
Reply With Quote
(#9 (permalink))
Old
Bad Karma[CORE]'s Avatar
Senior Member
Bad Karma[CORE] is on a distinguished road
 
Posts: 274
Join Date: May 2008
Send a message via ICQ to Bad Karma[CORE] Send a message via AIM to Bad Karma[CORE] Send a message via MSN to Bad Karma[CORE] Send a message via Yahoo to Bad Karma[CORE] Send a message via Skype™ to Bad Karma[CORE]
Default 07-17-2008, 07:15 PM

well, it could work if the URL that triggers the query would pass on the members id, like
http://blahhhhh.com/bleh/member.php?id=3 or something

This part of the code breaks the query:
PHP Code:
WHERE id='$id'"; 


(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
While Bunny is doing that you might as well visit my Blog
5 Bucks Script Installation Services
Free Web Hosting
Reply With Quote
(#10 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 354
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 07-17-2008, 07:27 PM

Right he needs to add $_GET["id"]; in top of this $query="SELECT * FROM users WHERE id='$id'";
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0
vBulletin Skin developed by: vBStyles.com