473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Error while fetching values from table containing login info

Hello

I'm experiencing a problem;

I've written a small script where volunteers can be booked for work-activities at a festival.
The festival has 5 different departments so i've created a database-table named "COORDINATOR" where all 5 usernames, password (md5 protected) and short description of the departments are located.

When a volunteer is getting booked by a certain festivaldepartment, the earlier mentioned description of the department should be added to a SIGNUP table so its easy to see for everyone where a certain volunteer will work at the festival (behind a bar, or building the stage etc..)

To get the right department-description, I use the username that is used at the current session.

But...when I query the code, I get an error. The third query gives me an error ("Mysql Error 3") back but i don't see why.
As far as I see..the code should be working :/ (I used lowercase fieldnames in the COORDINATOR table by the way)


Part of the code;

[php]

<?

// Check Login

if($logged_in){
echo 'Logged in as '.$_SESSION["username"].', <a href="logout.php">logout</a>';


// Get ID Of Volunteer From The Previous Page

$VRIJWILLIGER_ID = $_GET["id"];


// Query Details Of Volunteer

$query = "SELECT VOLUNTEER_ID, FIRSTNAME, LASTNAME, ADDRESS, ZIPCODE, CITY, TELEPHONE, AVAILABLE FROM VOLUNTEER
where VOLUNTEER_ID = $VOLUNTEER_ID";

$result = mysql_query($query)
or die("Mysql Error 1");


// Query Amount Of Days That The Volunteer Is Available For Work

$query = "SELECT DAYS FROM SIGNUP
where VOLUNTEER_ID = $VOLUNTEER_ID";

$result_days = mysql_query($query)
or die("Mysql Error 2");


// Assign The Username From The Session To Loginname

$loginname = $_SESSION["username"];


// Get The Right Username Using The Loginname

$query = "SELECT description FROM COORDINATOR
where username = $loginname";

$result_username = mysql_query($query)
or die("Mysql Error 3");


[/php]
Oct 16 '06 #1
9 1642
ronverdonk
4,258 Expert 4TB
Change your statement and you'll see what the exact error is.[php] or die('Mysql Error 3: ' . mysql_error()); [/php]
Ronald :cool:
Oct 16 '06 #2
okay thanks :)

using that function i see this error;

"Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/livesets-online.com/www/topics/boekvrijwilliger.php on line 56"


line 56 is this line;

$location=mysql_result($result_username,$i,"omschr ijving");

(nothing wrong with this as far as i can see..although im only a php noob ;-) )

the value of $location will be updated in the sign_up table so all festival-departments can see where a certain volunteer will work :)
Oct 16 '06 #3
ronverdonk
4,258 Expert 4TB
How can you request column name "omschrijving" when you only select column "description"?

Ronald :cool:
Oct 16 '06 #4
sorry, i had forgotten to translate that specific line of my script to be able to request help here :)

i meant;

$location=mysql_result($result_username,$i,"descri ption");
Oct 16 '06 #5
ronverdonk
4,258 Expert 4TB
sorry, i had forgotten to translate that specific line of my script to be able to request help here :)

i meant;

$location=mysql_result($result_username,$i,"descri ption");
How about the content of the $i variable? Should start at 0, but does it??

Ronald :cool:
Oct 16 '06 #6
till half an hour ago i hadn't read much of how it works with rows and assigning with results , but now i know a little bit more..

i changed the code to this but still no result (and the same error-message)

[php]

$loginname = $_SESSION["username"];

$query = "SELECT description FROM COORDINATOR
where username = $loginname";


$result = mysql_query($query);
if (!$query) {
die('Invalid query: ' . mysql_error());
}

$i=0;

$location=mysql_result($result,$i,"description");
[/php]

by the way; when i look at the database, the value of location in the sign-up has been changed from NULL to blank.
is this correct? i mean ..should the value been updated although there is no valid value assigned to $location?

rest of the code;
[php]

// Set availability to NO

$available="no";


// Update the availability of the volunteer at the signup table

$query= "UPDATE VOLUNTEER SET AVAILABLE = '$available' WHERE VOLUNTEER_ID = $VOLUNTEER_ID";
$result = mysql_query($query)
or die("Mysql error 4");

// Update the location where the volunteer will work

$query= "UPDATE SIGNUP SET LOCATION = '$location' WHERE VOLUNTEER_ID = $VOLUNTEER_ID";
$result = mysql_query($query);

if (!$query) {
die('Invalid query: ' . mysql_error());
}
[/php]
Oct 16 '06 #7
ronverdonk
4,258 Expert 4TB
You must not check $query, because that is just the SQL statement variable. You should test the result of the mysql_query command, so
[php]if (!$result) {[/php]

If $location variable containsed a blank your row was updated with that blank.

Ronald :cool:
Oct 16 '06 #8
if (!$result) { echo "blablabla";
}

and it echoes blablabla so something must be wrong than regarding the selection statement.
lets see if i can figure out what
Oct 16 '06 #9
i finally figured it out;

query had to be;

$query = "SELECT description FROM COORDINATOR
where username = '$loginname'";

instead of

$query = "SELECT description FROM COORDINATOR
where username = $loginname";

(notice the single quotes)
i didn't know i had to use them...anyway...maybe till soon when i have a new question :p
Oct 16 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
18
by: Steve | last post by:
Hi I have a really weird problem and any assistance would be welcome. I have developed an app in Access 2002. The app runs perfectly on the development machine. I have packaged the app using...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
1
by: fl | last post by:
I am running ASPNET on my local machine. I have a problem when I try to connect to a SQL server database table. The data looks good when I right click SqlDataAdapter1 to preview the data. When F5...
3
by: amatuer | last post by:
ADODB.Recordset error '800a0cb3' Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. /devag/newProjSave.asp, line 321 ...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: anilareddy | last post by:
Sometime back I had a posted an issue here. I was adviced to use AJAX in my application. I was not aware of it, somehow i managed to use it in. Now its working except few small issues. If anyone...
16
rpnew
by: rpnew | last post by:
Hello friends.... I'm developing one project in PHP-MySql on FC4..... I'm facing a problem here at one place. Let me describe it.... I've one page in php on which i'm generating a table...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.