PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 9th, 2012, 11:22 PM
ohmynexus ohmynexus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 ohmynexus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 36 sec
Reputation Power: 0
Question Issue with mysql_result

Wasn't sure if to post this here or in Mysql, but since it involves a lot of php I decided to put it here.

Having an issue setting up a profile page system. More specifically with retreiving the biography or about me portion of someones profile from a database.

Heres the code:
Code Code:
Original - Code Code
    if (isset($_GET['view']))     {         $viewUser = sanitizeString($_GET['view']);         $query = "SELECT * FROM gtmembers WHERE user='$viewUser'";         $result = queryMysql($query);         if (mysql_num_rows($result))         {             $bio = mysql_result($result,1,'text');             if ($viewUser == $user)             {                 if ($bio == "") $bio = "No bio set. Create one now!";                 echo $viewUser;                 echo <<<_END                     <form method='post' action='gtprofile.php?view=$user'>                     <textarea name='setBio' cols='40' rows='3'>$bio</textarea><br />                     <input type='hidden' name='myUser' value='$user' />                     <input type='submit' value='Update' />                     </form> _END;             }             else             {                 if ($bio == "") $bio = "User has not yet created their bio.";                 echo $viewUser . "<br />";                 echo $bio;             }         }         else echo "User does not exist.";     }



And the error:
Warning: mysql_result(): Unable to jump to row 1 on MySQL result index 6 in C:\gtcom\gtprofile.php on line 27

And the table:
createTable('gtprofile', 'user VARCHAR(16), text VARCHAR(4096), INDEX(user(6))');

Line 27 is bold and underlined.

I've tried many variations of mysql_result (even tho its slower than fetch_array and others I only need the value of text) but still the same issue. Compared to similar code, this seems like it would work.

The code basically checks to see if the user viewing the profile is the owner, and if they are it displays a form that lets them change their profile. Otherwise, it just displays that user's profile.

Also, usernames are unique.

Reply With Quote
  #2  
Old November 10th, 2012, 12:13 AM
ohmynexus ohmynexus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 ohmynexus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 36 sec
Reputation Power: 0
Question Issue with mysql result

Having an issue setting up a profile page system. More specifically with retreiving the biography or about me portion of someones profile from a database.

Heres the code:
PHP Code:
if (isset($_GET['view']))
    {
        
$viewUser sanitizeString($_GET['view']);
        
$query "SELECT * FROM gtmembers WHERE user='$viewUser'";
        
$result queryMysql($query);
        if (
mysql_num_rows($result))
        {
            
$bio mysql_result($result,1,'text');//This line is erroring
            
if ($viewUser == $user)
            {
                if (
$bio == ""$bio "No bio set. Create one now!";
                echo 
$viewUser;
                echo <<<_END
                    <form method='post' action='gtprofile.php?view=$user'>
                    <textarea name='setBio' cols='40' rows='3'>
$bio</textarea><br />
                    <input type='hidden' name='myUser' value='
$user' />
                    <input type='submit' value='Update' />
                    </form>
_END;
            }
            else
            {
                if (
$bio == ""$bio "User has not yet created their bio.";
                echo 
$viewUser "<br />";
                echo 
$bio;
            }
        }
        else echo 
"User does not exist.";
    } 



And the error:
Warning: mysql_result(): Unable to jump to row 1 on MySQL result index 6 in C:\gtcom\gtprofile.php on line 27

And the table:
createTable('gtprofile', 'user VARCHAR(16), text VARCHAR(4096), INDEX(user(6))'); //a function i made to make tables

Line 27 has comment beside it

I've tried many variations of mysql_result (even tho its slower than fetch_array and others I only need the value of text) but still the same issue. Compared to similar code, this seems like it would work.

The code basically checks to see if the user viewing the profile is the owner, and if they are it displays a form that lets them change their profile. Otherwise, it just displays that user's profile.

Also, usernames are unique.

Reply With Quote
  #3  
Old November 10th, 2012, 04:52 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,833 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 16 m 47 sec
Reputation Power: 811
Hi,

the row numbers start with 0, so you have to use

PHP Code:
 mysql_result($result0'text'


By the way, did your really use your createTable() function? I can hardly believe that it works, because "user" and "text" are all reserved words. If you simply copy this string into a "CREATE TABLE" query, you should get all kinds of syntax errors.

Reply With Quote
  #4  
Old November 10th, 2012, 07:01 AM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,867 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Week 5 Days 9 h 6 m 6 sec
Reputation Power: 581
Do you really want the 2nd returned row? The rows from MySQL are zero based. If it returns only 1 row, the first and only row will be number zero. If only 1 row is returned by your query then you will get exactly the error you are seeing. Perhaps this is what you really mean:
PHP Code:
 $bio mysql_result($result,0,'text'); 


P.S. I suggest you not use the depreciated MySQL extensions but PDO instead. Also please enclose your PHP code in [ PHP ] tags rather than [ CODE ] tags. See ManiacDan's New User Guide.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Last edited by gw1500se : November 10th, 2012 at 07:04 AM.

Reply With Quote
  #5  
Old November 10th, 2012, 07:58 AM
cafelatte cafelatte is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2008
Posts: 1,923 cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level)cafelatte User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 16 h 21 m 8 sec
Reputation Power: 377
Neither user nor text are reserved in MySQL. They are deliberately exempted.

Reply With Quote
  #6  
Old November 10th, 2012, 12:00 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,791 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 14 h 53 m 20 sec
Reputation Power: 6112
Threads merged since they had a similar title and same error message.
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #7  
Old November 10th, 2012, 03:07 PM
ohmynexus ohmynexus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 ohmynexus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 36 sec
Reputation Power: 0
Quote:
Originally Posted by Jacques1
Hi,

the row numbers start with 0, so you have to use


This worked, but now i'm getting this error:
Warning: mysql_result(): text not found in MySQL result index 6 in C:\gtcom\gtprofile.php on line 27

I changed the if bio = "" to if bio = NULL but still nothing.

Reply With Quote
  #8  
Old November 10th, 2012, 03:39 PM
ohmynexus ohmynexus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 ohmynexus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 36 sec
Reputation Power: 0
Wow I'm an idiot.

The error lies here:
PHP Code:
 $query "SELECT * FROM gtmembers WHERE user='$viewUser'"


The text should say:
PHP Code:
 $query "SELECT * FROM gtprofile WHERE user='$viewUser'"


The table gtmembers stores login information and nothing else. The table should direct to gtprofile where bios, and images and such will be stored.

:facepalm:

Thanks for the help!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Issue with mysql result

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap