PDA

View Full Version : phrase error here?


Dimava
Sun 19th May '02, 7:52pm
how come i'm getting a phrase error on this line:


if ( $category == '3' ) {


thanks

-Dimava

scoutt
Mon 20th May '02, 11:22am
unless it is because it has all that space in there it should produce a parse error. what is the line after that?

Dimava
Tue 21st May '02, 1:09am
here's the full code:


<html>
<head>
<title>Tutorial Submission</title>
</head>
<?php include("../templates/header.htm"); ?>
<?
require("config.php");

if ( $title == "") {
// input form
include("templates/tutorial_input.php");
}

if ( $title != "") {
// processing unit
$link = mysql_pconnect( "localhost", $user, $pass );
mysql_select_db( $db, $link );

$query = "INSERT INTO tutorials ( title, username, images, group, description ) values ( '$title', '$username', '$images', '$category', '$description' )";
//mysql_query($query);
print $category;
print $images;
include("templates/news_added.php");

//next table

$result = mysql_query("SELECT * FROM tutorial_amount where id='1' ");
while(list($one, $two, $three, $four, $five, $six, $seven, $eight, $nine, $ten, $eleven ) = mysql_fetch_row($result)){
print $eleven;

if ( $category == '1' ) {
$one = $one + 1;
}

if ( $category == '2 ) {
$two = $two + 1;
}

if ( $category == '3' ) {
$three = $three + 1;
}

if ( $category == '4' ) {
$four = $four + 1;
}

if ( $category == '5' ) {
$five = $five + 1;
}

if ( $category == '6' ) {
$six = $six + 1;
}

if ( $category == '7' ) {
$seven = $seven + 1;
}


if ( $category == '8' ) {
$eight = $eight + 1;
}

if ( $category == '9' ) {
$nine = $nine + 1;
}

if ( $category == '10' ) {
$ten = $ten + 1;
}

if ( $category == '11' ) {
$eleven = $eleven + 1;
}

mysql_close( $link );
}


include("../templates/footer.htm");
?>
</html>

GamerZ
Tue 21st May '02, 2:10am
ok look thru the code, wierd.

Steve Machol
Tue 21st May '02, 2:33am
Gamerz,

Please modify your sig so that it meets the vBulletin forum rules (http://www.vbulletin.com/forum/showthread.php?s=&threadid=42918). Thanks!

Signature Limits

All signatures should not exceed the following size limits, and you can't have both text and images
For text signatures: 4 lines normal size, 8 lines small size and up to 90 chars per line.
For images in signatures: 1 image up to 300 pixels wide, 125 pixels tall and 20k in size

Mark Hensler
Tue 21st May '02, 4:11am
forgot a quote...
if ( $category == '2 ) {

Mark Hensler
Tue 21st May '02, 4:16am
and try using a switch(), it's cleaner..

switch ($category) {
case 1: $one++; break;
case 2: $two++; break;
case 3: $three++; break;
case 4: $four++; break;
case 5: $five++; break;
case 6: $six++; break;
case 7: $seven++; break;
case 8: $eight++; break;
case 9: $nine++; break;
case 10: $ten++; break;
case 11: $eleven++; break;
}

Conscience
Tue 21st May '02, 4:26am
Originally posted by Mark Hensler
and try using a switch(), it's cleaner..

switch ($category) {
case 1: $one++; break;
case 2: $two++; break;
case 3: $three++; break;
case 4: $four++; break;
case 5: $five++; break;
case 6: $six++; break;
case 7: $seven++; break;
case 8: $eight++; break;
case 9: $nine++; break;
case 10: $ten++; break;
case 11: $eleven++; break;
}


hehe... I love how you always have very clean, concise code :D

and not only is that cleaner, it will execute faster

GamerZ
Tue 21st May '02, 7:35am
Originally posted by smachol
Gamerz,

Please modify your sig so that it meets the vBulletin forum rules (http://www.vbulletin.com/forum/showthread.php?s=&threadid=42918). Thanks!

ok sorry abt that, i have change it

Mark Hensler
Tue 21st May '02, 1:26pm
thx, Conscience

Even better would be to use an array. Then he could just....
$number[$category]++;

one liner :)

Dimava
Tue 21st May '02, 4:06pm
found it ! there wasn't a ' after the 3