Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-15-2008, 08:00 PM
zeroradius's Avatar   
zeroradius zeroradius is offline
Programmer
 
Join Date: Feb 2008
Location: Ohio
Posts: 197
Rep Power: 3
zeroradius is on a distinguished road
Send a message via AIM to zeroradius Send a message via Yahoo to zeroradius
Default Not outputting selected values?

Hi, I am curently working on a private messaging system in php. I started working on the final page (the view mail) and have ran into a snag. When you select the message it sends you to a page name view_sent.php?id="id here" it takes me to the new page and the corect Id shows in the address bar and no errors come out but the page does not return any information. right now i just have it returning the value of sender so i can get it working before i code the layout and return all of the information. Here is my code for the view_sent

PHP Code:

<?php
$id
=$_Get['id'];
$user="blah"// need to change to session later
$host="--------------"
$username="---------"
$password="---------";
$db_name="---------";  
$tbl_name="---------"


mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name Where id='$id'";
$result=mysql_query($sql);
$row mysql_fetch_row($result);
echo 
$row['sender'];
?>
__________________
"I would love to change the world ...... but they won't give me the sorce code"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-15-2008, 09:57 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,345
Last Blog:
PHP Function Overloadi...
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: Not outputting selected values?

Does
PHP Code:
echo $sql 
display what you are expecting? Does
PHP Code:
$result=mysql_query($sql) or die("Query Error: " mysql_error()); 
provide you with an error? What does
PHP Code:
print_r($result
yield?
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-17-2008, 08:57 AM
zeroradius's Avatar   
zeroradius zeroradius is offline
Programmer
 
Join Date: Feb 2008
Location: Ohio
Posts: 197
Rep Power: 3
zeroradius is on a distinguished road
Send a message via AIM to zeroradius Send a message via Yahoo to zeroradius
Default Re: Not outputting selected values?

1) Returns half of the sql statement cutting off at $id
2) No result
3) Resource id #2 (googleing this now, so far no usefull results)


Edit:
Hey John thanks for all the help. I got it working. I went and got the code from an old project from back when i used tutorials (now I make the schema and try to do it all myself)

the code looks simular and i still dont see what the problem was hertrs the working code

PHP Code:
$id=$_GET['id'];

$sql="SELECT * FROM $tbl_name WHERE id='$id'";

$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
echo 
$rows['sender']; 
(i had tryed array befor i posted and it was not working)
__________________
"I would love to change the world ...... but they won't give me the sorce code"

Last edited by zeroradius; 05-17-2008 at 09:44 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-24-2008, 09:52 AM
orjan orjan is offline
Learning Programmer
 
Join Date: Sep 2007
Posts: 36
Rep Power: 3
orjan will become famous soon enough
Default Re: Not outputting selected values?

I know the problem.

you used mysql_fetch_row() instead of mysql_fetch_array()

mysql_fetch_row() makes an array with index numbers only, mysql_fetch_array() makes an named array with fieldnames as keys to the field information.

it's simple, but hard to find in code.

then, you wrote $_Get first, and now $_GET, don't know if that makes difference ...

Last edited by orjan; 05-24-2008 at 09:59 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-24-2008, 11:43 AM
zeroradius's Avatar   
zeroradius zeroradius is offline
Programmer
 
Join Date: Feb 2008
Location: Ohio
Posts: 197
Rep Power: 3
zeroradius is on a distinguished road
Send a message via AIM to zeroradius Send a message via Yahoo to zeroradius
Default Re: Not outputting selected values?

as i said in my last post i had tried array before i posted here, and the capitals in get may have made a diffrence, but i do not think it will
__________________
"I would love to change the world ...... but they won't give me the sorce code"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 05-26-2008, 05:02 PM
orjan orjan is offline
Learning Programmer
 
Join Date: Sep 2007
Posts: 36
Rep Power: 3
orjan will become famous soon enough
Default Re: Not outputting selected values?

well, as $id was empty before, I think the capital thing was the matter :-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help streamlining averaging values from separate csv spreadsheets Natedawg1848 C and C++ 1 03-27-2008 10:21 PM
Best way to save lots of small values (in a database)? Vantage General Programming 2 05-14-2007 07:57 AM
attribute values question skilletsteve HTML Programming 1 09-30-2006 08:37 AM
Seperate values in a string Chan C# Programming 4 07-25-2006 09:17 AM
Sudoku can be solved using SQL..Take a look! roger Database & Database Programming 5 07-04-2006 02:20 PM


All times are GMT -5. The time now is 03:23 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads