Jump to content


Photo

A few things needing help on please.


  • Please log in to reply
10 replies to this topic

#1 RSprinkel

RSprinkel
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 17 September 2006 - 11:03 AM

Hi all,

I need some help here on a few things I am trying to do.

1) I am trying to create a form that I want data pulled out of a MySQL table called users from a column named sierra and then placed in a Drop Down box in the form.  I have searched here and tried many of the ideas here and apparently I am not grabbing the concept.

2) I want to have a form that pulls data from 3 different databases.  It is a profile form for my league.  When someone clicks on a members name the profile page will pull up displaying 3 different things.  1)Basic info on the member coming from the users table, Accomplishments within the league - Coming from the accomplishments table, and 3) Winnings - which would come from a win table.  All of these tables are in the same database. 

Thank you all very much in advance.


RSprinkel
A PHP/MySQL NOVICE I AM

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 17 September 2006 - 12:31 PM

Part 1

Choose a user: <select name="user">
<?php
// assumes database connection already exists
$query = "SELECT sierra from users";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
while ($row = mysql_fetch_array($result)) {
    echo "<option value='". $row['sierra']. "'>". $row['sierra']. "</option>\n";
?>
</select>

Legend has it that reading the manual never killed anyone.
My site

#3 RSprinkel

RSprinkel
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 17 September 2006 - 02:47 PM

Hi AndyB,

I am getting this error now when I inserted this code.

Parse error: syntax error, unexpected $end in /home/../../../../test.php on line 75

RSprinkel
A PHP/MySQL NOVICE I AM

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 September 2006 - 02:51 PM

what line is 75 then sorry my cristal ball not working.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 17 September 2006 - 02:52 PM

Choose a user: <select name="user">
<?php
// assumes database connection already exists
$query = "SELECT sierra from users";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
while ($row = mysql_fetch_array($result)) {
    echo "<option value='". $row['sierra']. "'>". $row['sierra']. "</option>\n";
} // close the loop, dummy
?>
</select>

My code, my fault, see fixed version above.
Legend has it that reading the manual never killed anyone.
My site

#6 RSprinkel

RSprinkel
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 17 September 2006 - 02:56 PM

what line is 75 then sorry my cristal ball not working.


LOL sorry I didn't post that and when I re-read what I wrote I was about to post it.

But no need to now.  It WORKS GREAT thank you very much for the update.

Again Thanks.
RSprinkel
A PHP/MySQL NOVICE I AM

#7 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 17 September 2006 - 03:07 PM

It's amazing how a little coffee reduces errors in my scripts :)

For future reference, that error message - and it probably references the line number after the end of your script - is symptomatic of an unclosed loop.
Legend has it that reading the manual never killed anyone.
My site

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 September 2006 - 03:30 PM

cheek your spelling of the varable.

also cheek that the varable is set and also your POSTING['correct name '];

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 RSprinkel

RSprinkel
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 17 September 2006 - 05:33 PM

Ok I got this script working now without any errors.  Now when I go to post the info into the database it posts everything but the sierra name into the db.  Man this PHP stuff is tuff, LOL.

Here is the process script.

<?php

include 'db.php';

$sierra = $_POST['sierra'];
$date = $_POST['date'];
$series = $_POST['series'];
$nmod = $_POST['nmod'];
$track = $_POST['track'];

$sierra = stripslashes($sierra);
$date = stripslashes($date);
$series = stripslashes($series);
$nmod = stripslashes($nmod);
$track = stripslashes($track);

//insert info into win table
$sql = mysql_query ("INSERT INTO win (sierra, date, series, nmod, track)
VALUES('$sierra','$date','$series','$nmod','$track')") or die (mysql_error());
if(!$sql){
	echo 'There has been an error processing your pirep. Please contact the webmaster.';
}

mysql_close($connection);

//show user decision page
include 'test_filed.php';
?>

All table fields are correct in the db and coincide with the script.

Again Thanks much for tolerating me and my NON PHP knowledge, LOL.


RSprinkel
A PHP/MySQL NOVICE I AM

#10 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 17 September 2006 - 05:48 PM

check the form to ensure that the name of the 'name' field in the input line is indeed sierra, spelling and case identical to the name of the variable you're expecting in the $_POST array.
Legend has it that reading the manual never killed anyone.
My site

#11 RSprinkel

RSprinkel
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 17 September 2006 - 06:02 PM

AndyB,

Thanks again very much for your expertise.  I did something dumb and changed the <select name="sierra"> to <select users="sierra">.  That is strictly my fault.  What a DUMB thing for me to do, LOL.

Again Thank You very much.  Working like a charm now.

RSprinkel
A PHP/MySQL NOVICE I AM




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users