Jump to content

N30Cr0n

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

About N30Cr0n

  • Birthday 09/22/1982

Contact Methods

  • Website URL
    http://www.smokingunz.co.uk

Profile Information

  • Gender
    Male
  • Location
    UK

N30Cr0n's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, I am costructing a booking form for work, and have almost all of the code working. The problem is, I had the 'save booking' page done, which would take the values from a form on another page, and add them to a database for use on the site. that worked perfectly, until i tried to add error checking into it, so that 2 things could not be booked at the same time/date/day etc. Below is the code for the savebooking.php, and everything after the '} else { doesnot work, so it will not add records any more. any ideas? <?php $pagename = "- Save Booking"; include( "./includes/header.php" ); // form post data vars $self = $_SERVER['PHP_SELF']; $roomname = $_POST['roomname']; $roomid = $_POST['room']; $date = $_POST['date']; $week = $_POST['week']; $day = $_POST['day']; $period = $_POST['period']; $year = $_POST['year']; $subject = $_POST['subject']; $name = $_POST['name']; // end // javascript redirector back to booking page echo "<script type=\"text/javascript\">\n" ."<!--\n" ."function redirection(){\n" ."window.location=\"./" . $roomid . "_bookings.php\"\n" ."}\n" ."//-->\n" ."</script>\n\n"; echo "<body onLoad=\"setTimeout('redirection()', 7500)\">\n\n"; //end $dbcnx=@mysql_connect( $dbhost, $dbuname, $dbpword ) or die( "<center><font color=\"red\"><b>ERROR: Could not connect to server, username and/or password incorrect. Try Again</b></font></center>" ); $rs=@mysql_select_db( $dbase, $dbcnx ) or die( "<center><font color=\"red\"><b>ERROR: Could not select database, does not exist. Try Again</b></font></center>" ); $sqlread="SELECT * FROM " . $roomid . "_bookings"; $rsread=mysql_query( $sqlread, $dbcnx ); while ( $rowread=mysql_fetch_array( $rsread ) ) { $dateread=stripslashes($rowread['date']); $weekread=stripslashes($rowread['week']); $dayread=stripslashes($rowread['day']); $periodread=stripslashes($rowread['period']); if ( $dateread == "$date" and $weekread == "$week" and $dayread == "$day" and $periodread == "$period" ) { echo "<table border=\"0\" width=\"90%\" cellpadding=\"5\" cellspacing=\"5\" align=\"center\">\n" ."<tr><td align=\"left\" class=\"headerborder\" bgcolor=\"#cccccc\">Previous Booking Found</td><tr>\n" ."<tr><td width=\"100%\" class=\"tableborder\" align=\"center\">\n\n" ."<table border=\"0\" width=\"75%\" cellpadding=\"5\" cellspacing=\"5\" align=\"center\">\n" ."<tr><td width=\"100%\">I'm sorry, but there is already a previous lesson timetabled for <b>$week</b>, <b>$day</b> <b>$date</b>, <b>$period</b>. Please return to the <a href=\"./" . $roomid . "_bookings.php\" target=\"_top\">" . $roomname . " Booking Sheet</a> and try again.</td></tr>\n" ."<tr><td width=\"100%\">This page should automatically return to the $roomname booking page in approx. 7 seconds, if it does not, please <a href=\"./" . $roomid . "_bookings.php\" target=\"_top\">Click Here</a></td></tr>\n" ."</table>\n\n" ."</td></tr>\n" ."</table>\n\n"; } elseif ( $dateread != "$date" and $weekread !="$week" and $dayread != "$day" and $periodread != "$period" ) { if ( $date and $week and $day and $period and $year and $subject and $name ) { # ensure values exist $sqlin="INSERT INTO " . $roomid . "_bookings ( date, week, day, period, year, subject, name ) values ( \"$date\", \"$week\", \"$day\", \"$period\", \"$year\", \"$subject\", \"$name\" )"; $rsin=mysql_query( $sqlin, $dbcnx ); echo "<table border=\"0\" width=\"90%\" cellpadding=\"5\" cellspacing=\"5\" align=\"center\">\n" ."<tr><td align=\"left\" class=\"headerborder\" bgcolor=\"#cccccc\">Booking Saved</td><tr>\n" ."<tr><td width=\"100%\" class=\"tableborder\" align=\"center\">\n\n" ."<table border=\"0\" width=\"75%\" cellpadding=\"5\" cellspacing=\"5\" align=\"center\">\n" ."<tr><td width=\"100%\">Thank you $name, your booking has been saved, and the details are shown below.</td></tr>\n" ."<tr><td>\n\n" ."<table border=\"0\" width=\"75%\" cellpadding=\"5\" cellspacing=\"5\" align=\"center\" class=\"tableborder\">\n" ."<tr><td width=\"25%\" align=\"right\">Room:</td><td width=\"35%\" align=\"left\"><b>$roomname</b></td><td width=\"15%\" align=\"right\">Date:</td><td width=\"25%\" align=\"left\"><b>$date</b></td></tr>\n" ."<tr><td align=\"right\">Week:</td><td align=\"left\" colspan=\"3\"><b>$week</b></td></tr>\n" ."<tr><td align=\"right\">Day:</td><td align=\"left\"><b>$day</b></td><td align=\"right\">Period:</td><td align=\"left\"><b>$period</b></td></tr>\n" ."<tr><td align=\"right\">Year Group:</td><td align=\"left\"><b>$year</b></td><td align=\"right\">Subject:</td><td align=\"left\"><b>$subject</b></td></tr>\n" ."<tr><td align=\"right\">Teacher:</td><td align=\"left\" colspan=\"3\"><b>$name</b></td></tr>\n" ."</table>\n\n" ."</td></tr>\n" ."<tr><td width=\"100%\">This page should automatically return to the $roomname booking page in approx. 7 seconds, if it does not, please <a href=\"./" . $roomid . "_bookings.php\" target=\"_top\">Click Here</a></td></tr>\n" ."</table>\n\n" ."</td></tr>\n" ."</table>\n\n"; } } } include( "./includes/footer.php" ); ?> Thanks Guys N30Cr0n
  2. [quote author=fenway link=topic=103398.msg412468#msg412468 date=1155132443] OK... so what part are you having trouble with? [/quote] well, i would like someone to help me get this code working, to do what i would lik it so people can only see their personal data when they have logged in. because this area of the site is only accessible when a login has been successful, then it doesnt matter about a non user page, as its not accessible. here is the page code i have so far, and a screen shot of the output i get when i try to load it up; [code]<?php if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {     die ("You can't access this file directly..."); } require_once("mainfile.php"); -$module_name = basename(dirname(__FILE__)); get_lang($module_name); $pagetitle = "- August 2006 Predict-a-Score"; /**********************************/ /* Configuration                  */ /*                                */ /* $index = 0; (right side off)   */ /**********************************/ $index = 0; $subject = "$sitename August 2006 Predict-a-Score"; /**********************************/ include("header.php"); global $entrant, $prediction, $prefix, $db, $userses; // select session data from nuke_session $userses = "SELECT uname FROM ".$prefix."_session WHERE uname='$username'"; echo mysql_query() . " - userses = SELECT uname FROM prefix _session WHERE uname=' username' <br>"; $result = $db->sql_query($userses); echo mysql_query() . " - result = db -> sql_query( userses); <br>";     $entrant = $db->sql_fetchrow($result); echo mysql_query() . " - entrant = db -> sql_fetchrow( result); <br>"; $prediction = $db->sql_query("SELECT id, team_a, team_b, date, time, score_a, score_b FROM predictions_".$entrant." ORDER BY date ASC"); $aug01 = $db->sql_query("SELECT team_a, team_b, date, time, score_a, score_b FROM predictions_".$entrant." WHERE date = '2006-08-19' ORDER BY date ASC"); if ($db->sql_numrows($prediction) == 0) {    include("header.php");    include("footer.php"); } if ($db->sql_numrows($prediction) > 0) {     $r_options = "";     if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }     if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }     if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; } OpenTable(); echo "<center><font class=\"title\">Current Registered Users</font><br><br>"     . "<font class =\"content\">Below you will find a list of Users currently Registered on Smokin Gunz [SG] Evolution, orderd by Registration Date, Latest First. Click on the UserNames to see Members Profiles.</font></center><br>"; echo "<center><table border=\"0\" width=\"620\" align=\"center\" cellpadding=\"1\">"     . "<tr><td align=\"center\" width=\"125\" bgcolor=\"#6a6eff\"><b>Home Team</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Score</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"25\" bgcolor=\"#6a6eff\"><b>v</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Score</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"125\" bgcolor=\"#6a6eff\"><b>Away Team</b></td><td align=\"center\" width=\"20\"> </td><td align=\"center\" width=\"100\" bgcolor=\"#6a6eff\"><b>Date</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"100\" bgcolor=\"#6a6eff\"><b>Time</b></td></tr>";     while ($row = $db->sql_fetchrow($aug01)) { $team_a = stripslashes($row['team_a']); $team_b = stripslashes($row['team_b']); $date = stripslashes($row['date']); $time = stripslashes($row['time']);   $score_a = stripslashes($row['score_a']); $score_b = stripslashes($row['score_b']);     echo "<tr><td align=\"center\" width=\"125\" bgcolor=\"#d6d7ff\">$team_a</td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#d6d7ff\">$score_a</td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"25\" bgcolor=\"#d6d7ff\"><b>v</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#d6d7ff\">$score_b</td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"125\" bgcolor=\"#d6d7ff\">$team_b</td><td align=\"center\" width=\"20\"> </td><td align=\"center\" width=\"100\" bgcolor=\"#d6d7ff\">$date</td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"100\" bgcolor=\"#d6d7ff\">$time</td></tr>";         } echo "</center></table>"; } echo "<br>"; echo "<center><a href=\"modules.php?name=PredictaScore\">Back to Prediction Selection</a></center>"; CloseTable(); include("footer.php"); ?>[/code] here is a pic of what i get when i use the above code; [img]http://www.wellfield.durham.sch.uk/images/select_error.gif[/img] (if pic not visable, please visit [url=http://www.wellfield.durham.sch.uk/images/select_error.gif]http://www.wellfield.durham.sch.uk/images/select_error.gif[/url]) and what i would like the output to look like (bearing in mind this next pic is of a different code alltogether, pullin data from a blank generic table, not a personal one) [img]http://www.wellfield.durham.sch.uk/images/select_correct.gif[/img] (if pic not visable, please visit [url=http://www.wellfield.durham.sch.uk/images/select_correct.gif]http://www.wellfield.durham.sch.uk/images/select_correct.gif[/url]) thanks
  3. [quote author=fenway link=topic=103398.msg411764#msg411764 date=1155047219] I'm not sure I understand what you're trying to do... you have a separate table for each user? [/quote] yes, each user has thier own table within the main database, say for example, predictions_johnsmith. john smith being the username. what i am after is when a user logs in using their username (johnsmith in this example) then this data is pulled from nuke_users, and stored in nuke_session, along with an ip and a time of login. all i want is to pull the username data back out of nuke_session, and use the it as a $var in a new select query, so that i can bring up the data from the corresponding predictions_ table hope that makes a little sense! lol
  4. Hi, i have been building a football prediction website, found here [url=http://premscore.smokingunz.co.uk]http://premscore.smokingunz.co.uk[/url], and i have run into a problem with part of the design. what i would like to happen, is that when a user logs in, the username is stored somehow, and then i can reference that username in a generic select statement, so i can create one page, but it will show different data depending on the username. i know this is done with sessions, and i am using php-nuke, which has a table called [b]nuke_sessions[/b], and this stores the username of all currently logged in users. so thats that session part covered, i can use that, but what i want is this, on a page called, say predicta.php, i want to start by pulling the session data for username from nuke_sessions, and then form a new query based on this, e.g. [code]<?php ....start of page code $sql = "SELECT uname FROM ".$prefix."_session WHERE uname='$username'"; //query to SELECT username data from session table $result = $db->sql_query($sql); $row2 = $db->sql_fetchrow($result); $entrant = $row2[uname]; $aug01 = $db->sql_query("SELECT id, team_a, team_b, date, time, score_a, score_b FROM predictions_".$entrant." WHERE date = '2006-08-19' ORDER BY date ASC"); //query to SELECT data from specific table based on session data selected above ....rest of page code below ?>[/code] so from that i would expect that it pick the username data from nuke_session, and store it for use in the select query to pick the data up from predictions_(username from session table) e.g. predictions_johnsmith, because johnsmith is the username logged in the session table. what i get, is the framework of the page, but no data, and when i [color=blue][b]echo[/b][/color] the sql queries, the output to the page is an empty line, so i am missing something, as the request is not being processed. can anybody spot it and help out/ solve it? thanks a million
  5. Hi, i have been building a football prediction website, found here [url=http://premscore.smokingunz.co.uk]http://premscore.smokingunz.co.uk[/url], and i have run into a problem with part of the design. what i would like to happen, is that when a user logs in, the username is stored somehow, and then i can reference that username in a generic select statement, so i can create one page, but it will show different data depending on the username. i know this is done with sessions, and i am using php-nuke, which has a table called [b]nuke_sessions[/b], and this stores the username of all currently logged in users. so thats that session part covered, i can use that, but what i want is this, on a page called, say predicta.php, i want to start by pulling the session data for username from nuke_sessions, and then form a new query based on this, e.g. [code]<?php ....start of page code $sql = "SELECT uname FROM ".$prefix."_session WHERE uname='$username'"; //query to SELECT username data from session table $result = $db->sql_query($sql); $row2 = $db->sql_fetchrow($result); $entrant = $row2[uname]; $aug01 = $db->sql_query("SELECT id, team_a, team_b, date, time, score_a, score_b FROM predictions_".$entrant." WHERE date = '2006-08-19' ORDER BY date ASC"); //query to SELECT data from specific table based on session data selected above ....rest of page code below ?>[/code] so from that i would expect that it pick the username data from nuke_session, and store it for use in the select query to pick the data up from predictions_(username from session table) e.g. predictions_johnsmith, because johnsmith is the username logged in the session table. what i get, is the framework of the page, but no data, and when i [color=blue][b]echo[/b][/color] the sql queries, the output to the page is an empty line, so i am missing something, as the request is not being processed. can anybody spot it and help out/ solve it? thanks a million
  6. [quote author=fenway link=topic=102570.msg409570#msg409570 date=1154703751] I'm still not seeing the final query string being passed to MySQL... [/quote] well thats probably my problem, i don't know how to do it, thats why i posting in here!! maybe point me in the right direction fenway??
  7. ok after hours of friggin around, i have come up blank. the page displays, meaning i have no major errors (i think) and i can enter new data into the text area i have set out, but as soon as i click the Update button on the form, the section of code that should write it all back to the datbase, doesn't work, it just refreshes the page, and removes all the data i have jus entered, and resets it back to its original values. i have changed a few things in the code, to clean it up and everything, and will post the new page code below. BTW, i am using PHP-Nuke 7.8 CMS as a framework, if that makes any difference. Thanks [code]<?php if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {     die ("You can't access this file directly..."); } require_once("mainfile.php"); -$module_name = basename(dirname(__FILE__)); get_lang($module_name); $pagetitle = "- Premier League Table Admin"; /**********************************/ /* Configuration                  */ /*                                */ /* $index = 0; (right side off)  */ /**********************************/ $index = 1; $subject = "$sitename Premier League Table Admin"; /**********************************/ include("header.php"); global $prefix, $db, $premadmin; $premadmin = $db->sql_query("SELECT team_id, team, played, points FROM wcs_premtable ORDER BY points DESC"); if ($db->sql_numrows($premadmin) == 0) {   include("header.php");   include("footer.php"); } if ($db->sql_numrows($premadmin) > 0) {     $r_options = "";     if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }     if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }     if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; } OpenTable(); echo "<center><font class=\"title\">Premiership League Table Admin</font><br><br>" . "<font class=\"content\"><b>ADMIN ONLY:</b> Here you can alter the number of games played and the points scored for each team, and it will be directly reflected on the Premiership League Table.</font></center><br><br>"; echo "<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width='100%'>"     ."<form name=\"PremAdmin\" action=\"modules.php?name=$module_name\" method=\"post\">"; echo "<center><table border=\"0\" width=\"210\" align=\"center\" cellpadding=\"1\">"     . "<tr><td align=\"center\" width=\"100\" bgcolor=\"#6a6eff\"><b>Team</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Played</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Points</b></td></tr>";     while ($row = $db->sql_fetchrow($premadmin)) { $team_id = stripslashes($row['team_id']); $team = stripslashes($row['team']); $played = stripslashes($row['played']); $points = stripslashes($row['points']); echo "<tr><td align=\"center\" width=\"100\" bgcolor=\"#d6d7ff\">$team</a></td><td align=\"center\" width=\"5\"> </td><td><input type=\"text\" name=\"tot_plyd\" value=\"$played\" size=\"6\" maxlength=\"5\"></td><td align=\"center\" width=\"5\"> </td><td><input type=\"text\" name=\"tot_pnts\" value=\"$points\" size=\"6\" maxlength=\"5\"></td></tr>";         } } echo "<tr><td colspan=\"5\" align=\"center\">"; echo "<input type=\"hidden\" name=\"team_id\" value=\"$premadmin[team_id]\">"; echo "<input type=\"hidden\" name=\"team\" value=\"$premadmin[team]\">"; echo "<input type=\"hidden\" name=\"op\" value=\"premup\">"; echo "<br><br><center><input class=button type=\"submit\" value=\"Update League\"></center>"; echo "</form></td></tr></table></center>";     CloseTable(); include("footer.php"); function premup($team_id, $team, $played, $points) { global $user_prefix, $db, $module_name, $premadmin; $db->sql_query("LOCK TABLES wcs_premtable WRITE"); print mysql_error() . "<br />"; $db->sql_query("UPDATE wcs_premtable SET played = '".$_POST["tot_plyd"]."', points = '".$_POST["tot_pnts"]."' WHERE team_id = '".$_POST["team_id"]."'"); print mysql_error() . "<br />"; $db->sql_query("UNLOCK TABLES"); print mysql_error() . "<br />";   Header("Location: modules.php?name=$module_name"); } switch($op) {     case "premup": premup($team_id, $team, $played, $points); break; } ?>[/code]
  8. ok after hours of friggin around, i have come up blank. the page displays, meaning i have no major errors (i think) and i can enter new data into the text area i have set out, but as soon as i click the Update button on the form, the section of code that should write it all back to the datbase, doesn't work, it just refreshes the page, and removes all the data i have jus entered, and resets it back to its original values. i have changed a few things in the code, to clean it up and everything, and will post the new page code below. BTW, i am using PHP-Nuke 7.8 CMS as a framework, if that makes any difference. Thanks [code]<?php if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {     die ("You can't access this file directly..."); } require_once("mainfile.php"); -$module_name = basename(dirname(__FILE__)); get_lang($module_name); $pagetitle = "- Premier League Table Admin"; /**********************************/ /* Configuration                  */ /*                                */ /* $index = 0; (right side off)   */ /**********************************/ $index = 1; $subject = "$sitename Premier League Table Admin"; /**********************************/ include("header.php"); global $prefix, $db, $premadmin; $premadmin = $db->sql_query("SELECT team_id, team, played, points FROM wcs_premtable ORDER BY points DESC"); if ($db->sql_numrows($premadmin) == 0) {    include("header.php");    include("footer.php"); } if ($db->sql_numrows($premadmin) > 0) {     $r_options = "";     if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }     if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }     if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; } OpenTable(); echo "<center><font class=\"title\">Premiership League Table Admin</font><br><br>" . "<font class=\"content\"><b>ADMIN ONLY:</b> Here you can alter the number of games played and the points scored for each team, and it will be directly reflected on the Premiership League Table.</font></center><br><br>"; echo "<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width='100%'>"     ."<form name=\"PremAdmin\" action=\"modules.php?name=$module_name\" method=\"post\">"; echo "<center><table border=\"0\" width=\"210\" align=\"center\" cellpadding=\"1\">"     . "<tr><td align=\"center\" width=\"100\" bgcolor=\"#6a6eff\"><b>Team</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Played</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Points</b></td></tr>";     while ($row = $db->sql_fetchrow($premadmin)) { $team_id = stripslashes($row['team_id']); $team = stripslashes($row['team']); $played = stripslashes($row['played']); $points = stripslashes($row['points']); echo "<tr><td align=\"center\" width=\"100\" bgcolor=\"#d6d7ff\">$team</a></td><td align=\"center\" width=\"5\"> </td><td><input type=\"text\" name=\"tot_plyd\" value=\"$played\" size=\"6\" maxlength=\"5\"></td><td align=\"center\" width=\"5\"> </td><td><input type=\"text\" name=\"tot_pnts\" value=\"$points\" size=\"6\" maxlength=\"5\"></td></tr>";         } } echo "<tr><td colspan=\"5\" align=\"center\">"; echo "<input type=\"hidden\" name=\"team_id\" value=\"$premadmin[team_id]\">"; echo "<input type=\"hidden\" name=\"team\" value=\"$premadmin[team]\">"; echo "<input type=\"hidden\" name=\"op\" value=\"premup\">"; echo "<br><br><center><input class=button type=\"submit\" value=\"Update League\"></center>"; echo "</form></td></tr></table></center>";     CloseTable(); include("footer.php"); function premup($team_id, $team, $played, $points) { global $user_prefix, $db, $module_name, $premadmin; $db->sql_query("LOCK TABLES wcs_premtable WRITE"); print mysql_error() . "<br />"; $db->sql_query("UPDATE wcs_premtable SET played = '".$_POST["tot_plyd"]."', points = '".$_POST["tot_pnts"]."' WHERE team_id = '".$_POST["team_id"]."'"); print mysql_error() . "<br />"; $db->sql_query("UNLOCK TABLES"); print mysql_error() . "<br />";    Header("Location: modules.php?name=$module_name"); } switch($op) {     case "premup": premup($team_id, $team, $played, $points); break; } ?>[/code]
  9. [quote author=fenway link=topic=102422.msg408080#msg408080 date=1154528875] What error are you getting? Could you post the interpolated query?  Are you sure that date/time are not reserved keywords that need to be backticked? [/quote] i dont get an error, i get a blank page! sorry!!
  10. [quote author=DocSeuss link=topic=102683.msg407992#msg407992 date=1154514492] on each of the lines after the lines containting a $db-> call  (just do the ones inside your function) [/quote] ok, have done that, and it made little diference. no error was reported, but the data still aint been saved to the table. DocSeuss, if you like i can PM you with the link to the page, and you can see what i wanting to do? here is the latest version of the page code, complete with suggested changes from this topic; [code]<?php if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {     die ("You can't access this file directly..."); } require_once("mainfile.php"); -$module_name = basename(dirname(__FILE__)); get_lang($module_name); $pagetitle = "- Premier League Table Admin"; /**********************************/ /* Configuration                  */ /*                                */ /* $index = 0; (right side off)  */ /**********************************/ $index = 1; $subject = "$sitename Premier League Table Admin"; /**********************************/ include("header.php"); global $prefix, $db; $premadmin = $db->sql_query("SELECT team_id, team, played, points FROM wcs_premtable ORDER BY points DESC"); if ($db->sql_numrows($premadmin) == 0) {   include("header.php");   include("footer.php"); } if ($db->sql_numrows($premadmin) > 0) {     $r_options = "";     if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }     if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }     if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; } OpenTable(); echo "<center><font class=\"title\">Premiership League Table Admin</font><br><br>" . "<font class=\"content\"><b>ADMIN ONLY:</b> Here you can alter the number of games played and the points scored for each team, and it will be directly reflected on the Premiership League Table.</font></center><br><br>"; echo "<table class=forumline cellpadding=\"3\" border=\"0\" width='100%'>"     ."<form name=\"PremAdmin\" action=\"modules.php?name=$module_name\" method=\"post\">"; echo "<center><table border=\"0\" width=\"210\" align=\"center\" cellpadding=\"1\">"     . "<tr><td align=\"center\" width=\"100\" bgcolor=\"#6a6eff\"><b>Team</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Played</b></td><td align=\"center\" width=\"5\"> </td><td align=\"center\" width=\"50\" bgcolor=\"#6a6eff\"><b>Points</b></td></tr>";     while ($row = $db->sql_fetchrow($premadmin)) { $team_id = stripslashes($row['team_id']); $team = stripslashes($row['team']); $played = stripslashes($row['played']); $points = stripslashes($row['points']); echo "<tr><td align=\"center\" width=\"100\" bgcolor=\"#d6d7ff\">$team</a></td><td align=\"center\" width=\"5\"> </td><td><input type=\"text\" name=\"played\" value=\"$played\" size=\"6\" maxlength=\"5\"></td><td align=\"center\" width=\"5\"> </td><td><input type=\"text\" name=\"points\" value=\"$points\" size=\"6\" maxlength=\"5\"></td></tr>";         } echo "</center></table>"; } echo "<br>"; echo "<input type=\"hidden\" name=\"team_id\" value=\"$team_id\">"; echo "<input type=\"hidden\" name=\"team\" value=\"$team\">"; echo "<input type=\"hidden\" name=\"played\" value=\"$played\">"; echo "<input type=\"hidden\" name=\"points\" value=\"$points\">"; echo "<input type=\"hidden\" name=\"op\" value=\"update\">"; echo "<center><input class=button type=\"submit\" value=\"Update Table\"></center>"; echo "</form>";     CloseTable(); include("footer.php"); function update($team_id, $team, $played, $points) { global $user_prefix, $db, $module_name;     $sql = "SELECT * FROM wcs_premtable LIMIT 0,30";     $result = $db->sql_query($sql); print mysql_error() . "<br />";     $row = $db->sql_fetchrow($result); print mysql_error() . "<br />"; $db->sql_query("LOCK TABLES wcs_premtable WRITE"); print mysql_error() . "<br />"; $db->sql_query("UPDATE wcs_premtable SET played = '$played', points = '$points' WHERE team_id = '$team_id'"); print mysql_error() . "<br />";     }   Header("Location: modules.php?name=$module_name"); switch($op) {     case "update": update($_REQUEST['team_id'], $_REQUEST['team'], $_REQUEST['played'], $_REQUEST['points']); break; } ?>[/code] thanks guys
  11. [quote author=DocSeuss link=topic=102683.msg407979#msg407979 date=1154513177] Throw this line in after each of your query calls [code] print mysql_error() . "<br />"; [/code] and see if you get any results I just put the break in there for troubleshooting in production code you wouldn't wan't anything to print out including the newline if mysql_error() didn't print an error. [/quote] ok, you will have to forgive me on this, but where would i put that little bit of code?
  12. [quote author=DocSeuss link=topic=102683.msg407971#msg407971 date=1154512507] If you have plugged that in and it still doesn't work then you have another problem that needs to be worked out. Unfortunatly if you are paying for a hosted site they may have error reporting turned off or down that you won't see the error you will just get a blank page. [/quote] well the page is still displaying, but the data isn't getting written back to the table within the database. after i press my update button, the page refreshes and the change i made haven't been stored. but in answer to the other thing about error reporting, yeah i just get a blank page when i f**k up the code! no error or nothing, which is so helpful! lol
  13. [quote author=DocSeuss link=topic=102683.msg407963#msg407963 date=1154511592] $_REQUEST is the superset of $_GET, $_POST, and $_COOKIE to expand on my answer when variables are send via a form you can't access them directly by just using $varname your have to use $_POST(assuming the method of your form was post) or you can use $_REQUEST which has access to all $_POST vars. ahh you posted while I was typing, just want to verify you would make those changes on the line the CALLS the function not in the function definition you can keep those the same. $_REQUEST['varname'] will yield the same result as $_POST['varname'] Now I'm sure there is an argument somewhere on all sides of the debate to say you should use one or the other but when it really comes down to it, it is just preference. [/quote] so, let me see if i have this straight; i would change; [code]function update($team_id, $team, $played, $points) { global $user_prefix, $db, $module_name;     $sql = "SELECT * FROM wcs_premtable LIMIT 0,30";     $result = $db->sql_query($sql);     $row = $db->sql_fetchrow($result); $db->sql_query("LOCK TABLES wcs_premtable WRITE"); $db->sql_query("UPDATE wcs_premtable SET played = '$played', points = '$points' WHERE team_id = '$team_id'");     }   Header("Location: modules.php?name=$module_name"); switch($op) {     case "update": update($team_id, $team, $played, $points); break; }[/code] to; [code]function update($team_id, $team, $played, $points) { global $user_prefix, $db, $module_name;     $sql = "SELECT * FROM wcs_premtable LIMIT 0,30";     $result = $db->sql_query($sql);     $row = $db->sql_fetchrow($result); $db->sql_query("LOCK TABLES wcs_premtable WRITE"); $db->sql_query("UPDATE wcs_premtable SET played = '$played', points = '$points' WHERE team_id = '$team_id'");     }   Header("Location: modules.php?name=$module_name"); switch($op) {     case "update": update($_REQUEST['team_id'], $_REQUEST['team'], $_REQUEST['played'], $_REQUEST['points']); break; }[/code] Thanks guys, who ever solves this will deffo get a mention in the comments!! lol
  14. [quote author=sw0o0sh link=topic=102683.msg407950#msg407950 date=1154510415] I think the guys saying, change the part that says.. [code] function update($team_id, $team, $played, $points) [/code] to [code] function update($_REQUEST["team_id"], $_REQUEST["team"], $_REQUEST["played"], $_REQUEST["points"]) [/code] [/quote] nope, tried that, and it buggered the page up completly, wouldn't load. thanks you guys, for all your input, keep it coming
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.