Jump to content

Archived

This topic is now archived and is closed to further replies.

Leovenous

*SOLVED* Blank screen, What gives in my script?

Recommended Posts

This is probably one of thos "duh" moments, but I've worked my mind into a scramble so an outsider might point out my blindness.

This is a processing page for a form. It takes information A, and checks to see if there is a B, C, D, F, and G. That dictates what all it needs to insert into the database. As it is now, it inserts that basic (player info) fine. The first insert query works. Its at the end, the pitcher option where it hangs. Its in a secure phpBB enviornment so you can't go to it, but I think its a pretty straightforward script.

The second query needs to insert the ID that is generated by auto_increment in the initial query. This is not complete, right now, because I'm trying to keep it simple. But eventually it will have to do up to 6 queries after the initial one, using the ID to relate them. That may be the sticking place. I don't know.

[code]
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
define('IN_PHPBB', true);
include "includes/functions.php";

// Start phpBB Session
// phpbbsession();

$phpbb_root_path = '../forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_MVPTIPS);
init_userprefs($userdata);
//
// End session management
//

// Make sure they belong here
//validate();
// CHECK if user is logged in
if (!$userdata['session_logged_in']) { 
    header ("Location: http://www.fanfaregames.com/forum/login.php");
  exit();
}
// CHECK to see if they are in the FRC
// Establish database connection
require_once('../../scripts/mysql_connect.php');
// Make a variable for comparison
$userid = $userdata['user_id'];
// Query the database on the ID of the user
$query = "SELECT frc_id FROM frc_users WHERE frc_id = '$userid' ";
$result = mysql_query ($query) or die(mysql_error());
// Check if they are legit
if(mysql_num_rows($result)<1) {
header ("Location: http://www.fanfaregames.com/frc/denied.php");
exit();
}
$active_game = $_GET['emag'];
// ***END STANDARD STUFF***

// Get POST's into variables
$fname = $_POST['Fname'];
$lname = $_POST['Lname'];
$team = $_POST['Team'];
$dob = $_POST['DOB'];
$pos = $_POST['Pos'];
$bathrow = $_POST['Bathrow'];
$careerpotential = $_POST['careerpotential'];
$dittytype = $_POST['batterdittytype'];
$number = $_POST['Number'];

// Check for pitcher data
if ($_POST['Pos'] == "SP" || $_POST['Pos'] == "RP") {
$windup = $_POST['Wstyle'];
$stamina = $_POST['Stam'];
$pickoff = $_POST['Pick'];

// Theyre'll always be a first pitch
$type1 = $_POST['Type1'];
$movement1 = $_POST['Movmt1'];
$control1 = $_POST['Cntrl1'];
$velocity1 = $_POST['Velo1'];

// Check for a second pitch
if ($_POST['Type2']) {
$type2 = $_POST['Type2'];
$movement2 = $_POST['Movmt2'];
$control2 = $_POST['Cntrl2'];
$velocity2 = $_POST['Velo2'];
}
// Check for a third pitch
if ($_POST['Type3']) {
$type3 = $_POST['Type3'];
$movement3 = $_POST['Movmt3'];
$control3 = $_POST['Cntrl3'];
$velocity3 = $_POST['Velo3'];
}
// Check for a fourth pitch
if ($_POST['Type4']) {
$type4 = $_POST['Type4'];
$movement4 = $_POST['Movmt4'];
$control4 = $_POST['Cntrl4'];
$velocity4 = $_POST['Velo4'];
}
// Check for a fifth pitch
if ($_POST['Type5']) {
$type5 = $_POST['Type5'];
$movement5 = $_POST['Movmt5'];
$control5 = $_POST['Cntrl5'];
$velocity5 = $_POST['Velo5'];
}
}
// Verify the data is present
if ($fname && $lname && $team && $dob && $pos && $bathrow && $careerpotential && $dittytype && $number) {

// Do the insert query
$query2 = "INSERT INTO mvp05_players (ID, Fname, Lname, Team, DOB, Pos, Batthrows, Carpotent, Ditty, Number, Creator_ID) VALUES (NULL, '$fname', '$lname', '$team', '$dob', '$pos', '$bathrow', '$careerpotential', '$dittytype', '$number', '$user_id')";
$result2 = mysql_query($query2) or die("Error: " . mysql_error());
if (mysql_affected_rows() == 1) {
// echo '<p><b>New Player Submitted</b></p>';
// exit();


// Check to see if we need to submit pitcher stuff
if ($_POST['Pos'] == "SP" || $_POST['Pos'] == "RP") {
$query3 = "INSERT INTO mvp05_pitchers (ID, delivery, stamina, pickoff) VALUES (LAST_INSERT_ID, $windup, $stamina, $pickoff)";
$result3 = mysql_query($query3) or die("Error: " . mysql_error());
if (mysql_affected_rows() == 1) {
header ("Location: http://www.fanfaregames.com/frc/verifypitcher.php");
  exit();
}
} else {
header ("Location: http://www.fanfaregames.com/frc/verify.php");
  exit();
}
} else {
echo 'There has been an error submitting this player. Contact Leovenous.';
}
}
?>
[/code]

Share this post


Link to post
Share on other sites
my best guess would be that the query is going through, but that one of the pages you're forwarding to (verifypitcher.php, etc) results in the blank page, not the processing script.

for the last inserted id, another option is to use mysql_insert_id(), which returns the ID inserted in the last query performed.  one way of checking where it is stalling is to use:

[code]exit('<pre>'.print_r(get_defined_vars(), TRUE));[/code]

this will cease the script wherever you put it and spit out any defined variables (with the local ones being at the bottom most often).  then you can take a look at exactly what variables have what values.  useful debugging line.

hope this helps.

Share this post


Link to post
Share on other sites
Thankyou, that worked like a champ!

I ended up dumping mysql_insert_id() into a normal variable, because I will be using it repeatedly. That code to view the variables is golden. Especially for seeing what I can access in the phpBB enviornment.

Cheers.

~Leo

Share this post


Link to post
Share on other sites

×

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.