Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
trouble calling information from the database
Old 12-23-2008, 09:59 PM trouble calling information from the database
Junior Talker

Posts: 2
Name: lady trupp. that is all.
Location: canadialand
Trades: 0
okay so, i'm a total newbie at php but i've been learning for a while. just recently i began to try my hand at writing scripts based off of other scripts, and then building up from there. so i based a user management script off of a registration/login script, and everything seems to work well except for two things:

1. When you view an individual user's profile, their information doesn't show up - only the information of the user thats logged in.

2. The profile information won't update even after a user edits it.

i think its something to do with the database not being able to call the information, or getting confused. i'm not quite sure. :/ but i have it all in a few different pages.

uviewscript.php:
(this is the script used to view the user pages)

PHP Code:
<?php
include_once('comerror.php');
include_once(
'db.php');

function 
user() {

echo 
"";

}

           
//dbConnect('user');

         
$sql_query "SELECT * FROM user WHERE id = '".$_GET['id']."'";
        
$sql_id mysql_query($sql) or die(mysql_error('A database error occurred in processing your submission.'));

        
$user mysql_fetch_row($sql_id);

//   $chname = $user['chname'];
//   $gender = $user['gender'];



$choice=$_GET['id'];

switch(
$choice)
{
case 
"$id":
include_once (
"user.php");
break; 

default:
user(); 




?>
and i call the information using <?=$user['chname']?>, etc on the users' page, user.php?id=*
* = the id of the user whos page is being viewed.

aaand ueditscript.php:
(this is the script used for editing the profile)

PHP Code:
<?php
include_once('comerror.php');
include_once(
'db.php');

function 
umenu() {

echo 
"";

}

$ucp[0] = "charedit";
$ucp[1] = "useredit";

$choice=$_GET['ucp'];

switch(
$choice)
{
case 
"$ucp[0]":
include_once (
"charedit.php");
break;

case 
"$ucp[1]":
include_once (
"useredit.php");
break; 

default:
umenu(); 



    if (!isset(
$_POST['submit'])):
           
// display user editttt;

    
else:
           
// processingggg lawl
           
dbConnect('user');

        
$_SESSION['logid'] = $logid;
        
$_SESSION['password'] = $password;

        
$sql "SELECT * FROM user WHERE
               logid = '
$logid' AND password = '$password'";

            if (
strlen($_POST['chname'])>'50') {
                   
error('Your character name is too long.');
                           }

        
$sql "UPDATE user SET
             chname = '"
.$_POST['chname']."',
             gender = '"
.$_POST['gender']."',
             age = '"
.$_POST['age']."',
             species = '"
.$_POST['species']."'
        WHERE 'id' ='
$id'";

       if (!
mysql_query($sql))
           
error('A database error occurred in processing your '.
                 
'submission.\\nIf this error persists, please '.
                 
'contact admin@soundtrack-howl.net.');


        
$chname $_POST['chname'];
        
$gender $_POST['gender'];
        
$age $_POST['age'];
        
$species $_POST['species'];

        
$cheditsuccess " <b>You have successfully editted your character!</b> <br /> <br /> ";


endif
?>
i'm aware that i'm lacking the age and species variables in uviewscript.php XD so um yeah. again, i'm a complete newb so i might be totally overlooking something... and if you need a closer look at the other scripts or the pages themselves, take a look here:

v1.soundtrack-howl.net

if you need to log in, just PM me and I'll give you info to the test account.

feel free to point out anything that looks like it should be changed. i'm in dire need of assistance xP
ladytrupp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-26-2008, 04:16 PM Re: trouble calling information from the database
Junior Talker

Posts: 2
Name: lady trupp. that is all.
Location: canadialand
Trades: 0
bump for help?
ladytrupp is offline
Reply With Quote
View Public Profile
 
Old 12-26-2008, 04:21 PM Re: trouble calling information from the database
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
I'd help you if I could, but currently I have the same problem.

- Steve
stevej is offline
Reply With Quote
View Public Profile
 
Old 12-31-2008, 04:43 PM Re: trouble calling information from the database
Junior Talker

Posts: 2
Trades: 0

Start by looking for `function dbConnect($var);` in the file db.php

This is selecting the user to load up the information in the variables.


Also in the first script it is getting the ID of the user from a _GET var so this is being passed on the command line.

Find the link and check the user_id in the call to make sure it is correct.

Beyond that you need to look in your server log usually at `/var/log/httpd/error_log` but this really depends upon your server.

The php error should be output here when you attempt the action.

Any other questions AFTER you have done this and I can help. Post the error here is you can retrieve one and we'll see what next.
__________________
GJP
Please login or register to view this content. Registration is FREE


Get a free
Please login or register to view this content. Registration is FREE
.
pomspot is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to trouble calling information from the database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13690 seconds with 12 queries