Forum Moderators: coopster

Message Too Old, No Replies

unexpected T_IF's and T_VARIABLES, BUT WHY?

         

ShoT

5:10 am on Mar 12, 2006 (gmt 0)

10+ Year Member



Okay,

Heres an unexpected T_IF:


if($submit)
{//begin of if($submit).
// Set global variables to easier names
$data = $_POST['data']

//Check if the "data" field is empty then print error message if necessary.
if(!$data){ //If its really empty.
echo "<br>Data field must not be empty. <br><br><b>- The Management.</b>";
exit();
}// End of if
// Write all to a CSV file

$csv = "whatever.csv";
if(!$fp = fopen($csv, "a")) die ("Cannot open data file");
array_shift($_REQUEST);
$size = sizeof($_REQUEST);
for($i=0; $i<$size; $i++) {
$str = $str . array_shift($_REQUEST);
if(!($i==($size-1))) {
$str = $str . ", ";
}
}
fwrite('$data');
// Print success message.
echo "<p>Thank You</p><p>The data was successfully saved.</p>";
}

Or this,

Unexpected T_VARIABLE


<?php
include("config.php");
$path = "../players/";
$max_size = 2000000;
//2 Mb, any bigger than that is overkill.

if (!isset($HTTP_POST_FILES['userfile'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "Rozmiar pliku jest ponad 2 Mb.<br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") ¦¦ ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") ¦¦ ($HTTP_POST_FILES['userfile']['type']=="

if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br>\n"; exit; }

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "Ladowanie Nie Pomyslne<br>\n"; exit; } else { echo "Ladowanie Pomyslne<br>\n"; }

// following line is for testing purposes only
echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";

} else { echo "Wrong file type<br>\n"; exit; }

}

if($Upload)
{//begin of if($Upload).
// Set global variables to easier names
$imgpath = $HTTP_POST_FILES['userfile']['name']

//run the query which adds the data gathered from the form into the database

$result = mysql_query("INSERT INTO recentimages (imgpath)
VALUES ('$imgpath')",$connect);

echo "<center><h2>Path added successfully into database.</h2></center>";

}//end of else

?>


Unexpected T_VARIABLE
Line 43: $result = mysql_query("INSERT INTO recentimages (imgpath)

Unexpected T_IF
Line 9: if(!$data){ //If its really empty.

Now, both are similiar, actually, based on this script which works correctly:


<?
include("config.php");
?>

<title>Add Show Info</title>

<?
if($submit)
{//begin of if($submit).
// Set global variables to easier names
$title = $_POST['title'];
$location = $_POST['location'];
$date = $_POST['mydate'];
$shortdesc = $_POST['shortdesc'];
$description = $_POST['description'];
$players = $_POST['players'];

//Check if the "title" field is empty then print error message if necessary.
if(!$title){ //If its really empty.
echo "Tytul musi byc podany, prosze wypelnij by kontynuowac. <br><br><b>- The Management.</b>";
exit(); //exit the script and don't do anything else.
}// End of if

//run the query which adds the data gathered from the form into the database
$result = mysql_query("INSERT INTO showinfo (title, location, mydate, shortdesc, description, players)
VALUES ('$title','$location','$mydate','$shortdesc','$description','$players')",$connect);
//print success message.
echo "<body bgcolor=#666666>";
echo "<br><br><br><h2 align=center><b>Show Info dodane pomyslnie!<br>Wrocisz do strony administracyjnej za (3) sekundy.</h2>";
echo "<meta http-equiv=Refresh content=3;url=index.php>";
}//end of if($submit).

Now, does anyone have any ideas because I am going crazy, Im out of nails to bite off, and I wont sink as low to start biting the toenails...

nfs2

5:59 am on Mar 12, 2006 (gmt 0)

10+ Year Member



wow what a mess.. Thats really hard to read.

I noticed at the top you have

if($submit)
{//begin of if($submit).
// Set global variables to easier names
$data = $_POST['data']

Maybe add a ; at the end like this

if($submit)
{//begin of if($submit).
// Set global variables to easier names
$data = $_POST['data'];

See if that helps

ShoT

8:03 am on Mar 12, 2006 (gmt 0)

10+ Year Member



Thanks man, wow, I cant believe I didn't notice it.