Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
LastCaress
May 8, 2004

bonobo
Oh, I did substitute that as well, but I got the error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site19/fst/var/www/html/rpg/club_join.pro.php on line 30

Sorry, should've made it clear.

EDIT : Ah, and I've corrected the way it updates member numbers, that was wrong as well.

Adbot
ADBOT LOVES YOU

Inquisitus
Aug 4, 2006

I have a large barge with a radio antenna on it.
:siren: MVC theory question: :siren:

I'm currently playing around with the Propel ORM framework and trying to work out how best to integrate it into Kohana (an MVC framework). My question is how should I go about transforming Propel's generated data objects when they're passed through the controller and into the view? Leaving them as they are would be exposing details of the data layer to the presentation layer, but constructing a new object for each one seems completely over the top.

Not sure how to proceed; please advise!

<deleted user>

Inquisitus posted:

:siren: MVC theory question: :siren:

I'm currently playing around with the Propel ORM framework and trying to work out how best to integrate it into Kohana (an MVC framework). My question is how should I go about transforming Propel's generated data objects when they're passed through the controller and into the view? Leaving them as they are would be exposing details of the data layer to the presentation layer, but constructing a new object for each one seems completely over the top.

Not sure how to proceed; please advise!

When applying MVC, it is absolutely normal for the view to get state from a model object directly. If you want to expose some other interface than what your ORM provides, maybe read up on the adaptor pattern.

opblaaskrokodil
Oct 26, 2004

Your morals are my morals. Your wishes are my code.

LastCaress posted:

Oh, I did substitute that as well, but I got the error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/virtual/site19/fst/var/www/html/rpg/club_join.pro.php on line 30

Sorry, should've made it clear.

EDIT : Ah, and I've corrected the way it updates member numbers, that was wrong as well.
Just to be clear, is line 30
php:
<?
header(error("club.php?game=$game&clubid=$clubid","Thank you for joining $getclub[name]."));?>
?

There are a couple of ways to fix it. You can either use string concatenation, so you would have
php:
<?
header(error("club.php?game=$game&clubid=$clubid","Thank you for joining " . $getclub['name'] . "."));?>
as your string. ( a dot between two strings concatenates them). Alternatively, you can wrap the variable in { }.
php:
<?
header(error("club.php?game=$game&clubid=$clubid","Thank you for joining {$getclub['name']}."));?>
Edit: Why is that an error call within a header call anyway? I'm not familiar with VPet, but it seems like a weird thing to be doing

opblaaskrokodil fucked around with this message at 20:06 on Apr 21, 2008

Jewish Bear
Jul 28, 2007

opblaaskrokodil posted:

Edit: Why is that an error call within a header call anyway? I'm not familiar with VPet, but it seems like a weird thing to be doing

It probably returns a Location: header.

opblaaskrokodil
Oct 26, 2004

Your morals are my morals. Your wishes are my code.

LOL AND OATES posted:

It probably returns a Location: header.

I guess it could be urlencoding the second param of error and appending that to the redirect URL or something then printing it out @ that page. Otherwise I don't know what the second param is for, since you can't print it out on the current page without loving up sending headers?

Zorilla
Mar 23, 2005

GOING APE SPIT

opblaaskrokodil posted:

Otherwise I don't know what the second param is for, since you can't print it out on the current page without loving up sending headers?

As far as I know, PHP won't send the HTTP header until it reaches the first HTML templated area or echo statement (or printf or whatever), so he's fine as long as it's not being set after one of these conditions gets met. Still, there's no need to set the header more than once, so the code should probably use elseif statements instead to make sure no more than one of these conditions gets evaluated as true at the same time:

php:
<?
if ($getclub['private'] == 1) {
    die(header(error("club.php?game=$game&clubid=$clubid","You can't join a private club.")));
} elseif ($clubrank > 0) {
    die(header(error("club.php?game=$game&clubid=$clubid","You are already a member of this club.")));
} elseif ($getmemberdata4['id']) {
    die(header(error("club.php?game=$game&clubid=$clubid","You are already a member of a club.")));
}
?>

Jimix
Jun 20, 2001

For some reason I cannot remember how to do this, or at least I swear that I had to do this for that PHP class I took a few years back...

So we have a trouble ticket system at my work that is written in PHP, and they want me to add some fields to the form. They want something like:

php:
<?
echo "is this a new instance? <INPUT TYPE=CHECKBOX NAME=instance>";

//HOW THE gently caress DO YOU DO THIS PART
if (instance == checked) { 
    echo "more input fields";
    ...
}

echo "<input type=submit name=submit>";
?>
for the life of me I cannot figure out how to have the code dynamically check and see if that first checkbox is clicked and then shoot out some more HTML if so, or hide the new fields if the checkbox becomes unclicked. or maybe even if(checkbox), display one set of fields, else display another set.

Zorilla
Mar 23, 2005

GOING APE SPIT
The variable you're checking for is $_POST["instance"] (or $_GET["instance"] depending on the form action) and its value is probably true if checked and false if not. I'm not 100% on this, so you might want to check by slipping in an echo $_POST["instance"]; in there somewhere and see what displays in your browser.

Also, I recommend using HTML templating instead of echo statements wherever possible, as it allows HTML sections to get context highlighted properly in editors such as Notepad++ and you don't have to explicitly state line breaks with "\n". The end result is something like this:

php:
<?
is this a new instance? <input type="checkbox" NAME="instance" /><br />
<?php
if ($_POST["instance"] == true) {
?>
more input fields<br />
<?php
}
?>
<input type="submit" name="submit" /><br />
?>

noonches posted:

I sounds like Jimix is trying to do it dynamically after the page loads based on user actions. In other words Javascript.

Yeah, if you're trying to make form fields appear in real time, just to it on the client side with Javascript.

Zorilla fucked around with this message at 21:03 on Apr 21, 2008

noonches
Dec 5, 2005

It represents my lifestyle and stratus as a street savy irreverent youth, who lives large, and yet hungers for the next level in life.
I sounds like Jimix is trying to do it dynamically after the page loads based on user actions. In other words Javascript.

opblaaskrokodil
Oct 26, 2004

Your morals are my morals. Your wishes are my code.

Zorilla posted:

As far as I know, PHP won't send the HTTP header until it reaches the first HTML templated area or echo statement (or printf or whatever), so he's fine as long as it's not being set after one of these conditions gets met. Still, there's no need to set the header more than once, so the code should probably use elseif statements instead to make sure no more than one of these conditions gets evaluated as true at the same time:

php:
<?
if ($getclub['private'] == 1) {
    die(header(error("club.php?game=$game&clubid=$clubid","You can't join a private club.")));
} elseif ($clubrank > 0) {
    die(header(error("club.php?game=$game&clubid=$clubid","You are already a member of this club.")));
} elseif ($getmemberdata4['id']) {
    die(header(error("club.php?game=$game&clubid=$clubid","You are already a member of a club.")));
}
?>

That seems kind of unnecessary to me, since die will stop the execution if any of them evaluate as true anyway (maybe a bit clearer from the point of reading, I guess).
What I was wondering about was where it was going to display to the user, for example, 'You are already a member of this club'.

---

Jimix posted:

So we have a trouble ticket system at my work that is written in PHP, and they want me to add some fields to the form. They want something like:

php:
<? echo "is this a new instance? <INPUT TYPE=CHECKBOX NAME=instance>"; //HOW THE gently caress DO YOU DO THIS PART if (instance == checked) { echo "more input fields"; ... } echo "<input type=submit name=submit>"; ?>



for the life of me I cannot figure out how to have the code dynamically check and see if that first checkbox is clicked and then shoot out some more HTML if so, or hide the new fields if the checkbox becomes unclicked. or maybe even if(checkbox), display one set of fields, else display another set.
If I understand you correctly, you want it to display the fields if someone checks the checkbox, without going to a different page / submitting the form? If so, you want something more like Javascript to do this. PHP processes the page server-side, and then sends the output to the browser. If you want to check the value of a checkbox via PHP, then you need to have the user submit the form (whereupon it will not be set if unchecked, or set to 'on' if it's checked), but unless you have them submit the page, PHP alone is not going to achieve what you want.

Something like this
Nevermind, the one below is a lot cleaner looking.

opblaaskrokodil fucked around with this message at 20:53 on Apr 21, 2008

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Jimix posted:

For some reason I cannot remember how to do this, or at least I swear that I had to do this for that PHP class I took a few years back...

So we have a trouble ticket system at my work that is written in PHP, and they want me to add some fields to the form. They want something like:

php:
<?
echo "is this a new instance? <INPUT TYPE=CHECKBOX NAME=instance>";

//HOW THE gently caress DO YOU DO THIS PART
if (instance == checked) { 
    echo "more input fields";
    ...
}

echo "<input type=submit name=submit>";
?>
for the life of me I cannot figure out how to have the code dynamically check and see if that first checkbox is clicked and then shoot out some more HTML if so, or hide the new fields if the checkbox becomes unclicked. or maybe even if(checkbox), display one set of fields, else display another set.

If I am understanding you, you do not want PHP for this, you want javascript.

code:
<script>
function blah(){
var myVis = (document.getElementById("isNewBox").checked) ? "block" : "none";
document.getElementById("extraFields").style.display = myVis;
}
</script>
<input type="checkbox" id="isNewBox" onclick="blah()" checked="checked" />
<div id="extraFields">
  <input type="text" />
  [ add your other bonus fields here ]
</div>

Jimix
Jun 20, 2001

I guess I just imagined writing something like what I had in mind in PHP, thanks for your help everybody!

Zorilla
Mar 23, 2005

GOING APE SPIT
Or better yet, using event handlers and DOM writing (no idea if this exact code works, but you get the idea):

code:
<html>
<head>
<script type="text/javascript">
window.onload = function() {
	var isNewBox = document.getElementById("isNewBox");
	var extraFields = document.getElementById("extraFields");

	isNewBox.onrelease = function() {
		extraFields.innerHTML += "[ add your other bonus fields here ]\n";
	}

}
</script>
</head>

<body>
<input type="checkbox" id="isNewBox" checked="checked" />
<div id="extraFields"> 
	<input type="text" /> 
	<!-- event handler writes stuff here -->
</div>
</body>
</html>

Zorilla fucked around with this message at 22:46 on Apr 21, 2008

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


Zorilla posted:

The variable you're checking for is $_POST["instance"] (or $_GET["instance"] depending on the form action) and its value is probably true if checked and false if not. I'm not 100% on this

Checkboxes will not appear in _GET/_POST if they are not checked. If they are checked, they will contain the contents of the value attribute. I don't know what they contain if there is no value attribute.

LastCaress
May 8, 2004

bonobo

opblaaskrokodil posted:

php:
<?
header(error("club.php?game=$game&clubid=$clubid","Thank you for joining " . $getclub['name'] . "."));?>

This returns "Thank you for joining ."

(maybe there's still a mistake in club.inc.php?


opblaaskrokodil posted:


php:
<?
header(error("club.php?game=$game&clubid=$clubid","Thank you for joining {$getclub['name']}."));?>
Edit: Why is that an error call within a header call anyway? I'm not familiar with VPet, but it seems like a weird thing to be doing


Returns the same. Vpet was a very incomplete game engine that I bought on an impulse (well not that expensive) and seems like an abandoned project.


EDIT:

Well, I put this:

$waga = 'lol';
header(error("club.php?game=$game&clubid=$clubid","Thank you for joining $waga"));

which returned : Thank you for joining lol

So I guess the problem lies somewhere in the club.inc.php file :\


EDIT 2:

I tried putting the $getclub = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'"); inside the club_join.pro.php but didn't work. So instead of mysql_query i put "fetch" . Don't ask my why, I had seen it in other parts of the code. It worked! So I put it in the club_inc and it didn't work. I don't get this at all :|


EDIT 3:

Maybe that header thinggie doesn't have access to the club_inc stuff?

EDIT 4:

I think I found the problem. The original was:

php:
<?
$getclub = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());
if (mysql_num_rows($getclub) == 0)
{
    die(header(error("club.php?game=$game","This is not a real club.")));
}?>
I removed the mysql_num_rows condition, replaced the mysql_query with the fetch command and I guess it's kinda working :|

LastCaress fucked around with this message at 22:56 on Apr 21, 2008

noonches
Dec 5, 2005

It represents my lifestyle and stratus as a street savy irreverent youth, who lives large, and yet hungers for the next level in life.

duz posted:

Checkboxes will not appear in _GET/_POST if they are not checked. If they are checked, they will contain the contents of the value attribute. I don't know what they contain if there is no value attribute.

They return "on". Checking for a value is unecessary unless you're using that value for some processing, if it's just a flag, on should work.

Possym
Oct 5, 2002
no pants? no problem!
hey so i'm working on my first php website and i've run into a problem with sessions.

index.php includes login.php

login.php is a basic username, password and login button. it does various checks to see if the user exists, if the passwords are correct. here is the part of the code i create the session. i set two variables (logged in, and uname) as session varibles than load the table of contents for the user.
php:
<?
if(md5($_POST['pword']) == $row[0]){
            //if they do, log the user in
            session_start();
            $_SESSION['loggedIn'] = true;
            $_SESSION['uname'] = $_POST['uname'];
            include "usertoc.php";
?>
this is the code for usertoc.php
php:
<?
<p>
    <?php print "<a href=\"user.php?uname=" .$_SESSION['uname']. "\">My Profile</a><br />"?>
    Add Data<br />
    Search<br />
    Browse<br />
    <hr width="85%" size="1px" color="#735511"/>
    <a href="logout.php">Logout</a><br />
</p>
?>
So far so good! Everything has worked up to this point. However, when I click on the My Profile link I go to the page, but my session is destroyed.

user.php
php:
<?php 
//figure out which link bar to include
    if(isset($_SESSION['loggedIn']))
        include "usertoc.php";
    else
        include "toc.php";
?>

It includes toc.php every time! I'm not experienced with sessions at all, did I do something to mess it up on accident?

opblaaskrokodil
Oct 26, 2004

Your morals are my morals. Your wishes are my code.

LastCaress posted:

EDIT 2:

I tried putting the $getclub = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'"); inside the club_join.pro.php but didn't work. So instead of mysql_query i put "fetch" . Don't ask my why, I had seen it in other parts of the code. It worked! So I put it in the club_inc and it didn't work. I don't get this at all :|

Oh, you are misinterpreting a bit what mysql_query returns. It returns a mysql resource object, which is not an associative array like you're using (or it returns false if there's an error in your query). To do what you wanted with using mysql_query, you'd have to do
php:
<?
$resource = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'"); 
$getclub = mysql_fetch_array($resource);
?>
It looks like fetch (which isn't a standard PHP function to my knowledge) is basically doing the above (returning the first row of the result of calling your query).

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


Possym posted:

It includes toc.php every time! I'm not experienced with sessions at all, did I do something to mess it up on accident?

Are you running session_start(); before you start messing with sessions or outputting anything?

Possym
Oct 5, 2002
no pants? no problem!

duz posted:

Are you running session_start(); before you start messing with sessions or outputting anything?

i don't really understand. after the login verifies, that is when i use session_start(). i don't output anything.

the flow is like this:
-index.php includes login.php
-from index.php i write my username and password and hit login.
--the code verifies the info is right and starts the session. it assigns two session variables some values.
-it reloads page with usertoc.php in the place of login and renders the dynamic link based on a session variable correctly.
-when i go to the user.php page from the link the session variables are null.

it's strange to me that the session variables when i click on one link, but for another they aren't.

noonches
Dec 5, 2005

It represents my lifestyle and stratus as a street savy irreverent youth, who lives large, and yet hungers for the next level in life.

Possym posted:

i don't really understand. after the login verifies, that is when i use session_start(). i don't output anything.

the flow is like this:
-index.php includes login.php
-from index.php i write my username and password and hit login.
--the code verifies the info is right and starts the session. it assigns two session variables some values.
-it reloads page with usertoc.php in the place of login and renders the dynamic link based on a session variable correctly.
-when i go to the user.php page from the link the session variables are null.

it's strange to me that the session variables when i click on one link, but for another they aren't.

If I had to guess, I'd say you aren't running session_start() first on user.php. session_start() has to be the first thing output, so it's best to just put it as the first line of code, or in an include thats on the top of every page.

Possym
Oct 5, 2002
no pants? no problem!
thank you so much. I put session_start on the top of all the pages and it's working now!

Snozzberry Smoothie
Jun 27, 2005

by Fragmaster
I need to generate XML with a PHP script, but I'm unsure of the best method from a performance perspective. Can anyone give me some advice or point me at a resource that I can read more on the topic?

EDIT: Is the most common way to just foreach and echo XML tags?

Snozzberry Smoothie fucked around with this message at 02:56 on Apr 22, 2008

Zorilla
Mar 23, 2005

GOING APE SPIT
A session question of my own: how do I get them to persist between browser sessions? The top of my login page looks like this:

(check_login() retuns true, false, or "admin" depending on outcome of username/password combo)

php:
<?
session_start();

if (!(@$_POST["submit"])) {
    session_destroy();
} else {
    $userstatus = check_login(@$_POST["username"], @$_POST["password"]);
    if (!$userstatus) {
        $error = "Invalid username or password.";
    } else {
        $_SESSION["loggedin"] = true;
        if ($userstatus == "admin") {
            $_SESSION["isadmin"] = true;
        }
        header("Location:index".PAGE_EXT);
    }
}
?>

And pages you can only access after being logged in look like this:

php:
<?
session_start();
if (@$_SESSION["loggedin"] != true) {
    header("Location:login".PAGE_EXT);
}
?>

I've tried setting cookie timeout, but that has no effect.

Zorilla fucked around with this message at 04:23 on Apr 22, 2008

Zorilla
Mar 23, 2005

GOING APE SPIT

Snozzberry Smoothie posted:

I need to generate XML with a PHP script, but I'm unsure of the best method from a performance perspective. Can anyone give me some advice or point me at a resource that I can read more on the topic?

EDIT: Is the most common way to just foreach and echo XML tags?

Here's the DOM approach to XML: http://www.ibm.com/developerworks/library/os-xmldomphp/

Or you could do something like this:

php:
<?php
$items = array("stuff""more stuff""holy crap here's some more stuff""boopty boop");

ob_start();

?>
<stuff>
<?php
foreach ($items as $item) {
?>
    <item><?php echo $item?></item>
<?php
}
?>
</stuff>
<?php

$xmldata ob_get_contents();
ob_end_clean();

$file fopen("items.xml""w");
fwrite($file$xmldata);
fclose($file);
?>



Both methods are probably blazing fast, but this probably has less overhead from not loading any classes - not that it matters for such a tiny task.

Zorilla fucked around with this message at 05:26 on Apr 22, 2008

noonches
Dec 5, 2005

It represents my lifestyle and stratus as a street savy irreverent youth, who lives large, and yet hungers for the next level in life.

Zorilla posted:

A session question of my own: how do I get them to persist between browser sessions? The top of my login page looks like this:

(check_login() retuns true, false, or "admin" depending on outcome of username/password combo)

I've tried setting cookie timeout, but that has no effect.

You'd need to set a cookie explicitly, a cookie timeout only works on an actual cookie, not a session.

I usually set a cookie with the value of some fields in the database hashed together, and have a separate login function that sets up the sessions if thats set and correct.

noonches fucked around with this message at 05:02 on Apr 22, 2008

Zorilla
Mar 23, 2005

GOING APE SPIT

noonches posted:

You'd need to set a cookie explicitly, a cookie timeout only works on an actual cookie, not a session.

Ok, I was trying using $_COOKIE in conjunction with $_SESSION without adjusting the default timeout value of "0" before giving up the first time, then only using $_SESSION when I tried setting cookie timeout the next time, so you can see why things didn't work. Looks like I've got a bit of modifications to do.

noonches posted:

I usually set a cookie with the value of some fields in the database hashed together, and have a separate login function that sets up the sessions if thats set and correct.

If the cookie data is nothing but a hash, how does it carry information about who is logged in between browser sessions? Or are you saying you store this in addition to a username and password cookie?

Zorilla fucked around with this message at 05:10 on Apr 22, 2008

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


Snozzberry Smoothie posted:

I need to generate XML with a PHP script, but I'm unsure of the best method from a performance perspective. Can anyone give me some advice or point me at a resource that I can read more on the topic?

EDIT: Is the most common way to just foreach and echo XML tags?

Use SimpleXML. It makes it so easy.

Zorilla posted:

Ok, I was trying using $_COOKIE in conjunction with $_SESSION without adjusting the default timeout value of "0" before giving up the first time, then only using $_SESSION when I tried setting cookie timeout the next time, so you can see why things didn't work. Looks like I've got a bit of modifications to do.


If the cookie data is nothing but a hash, how does it carry information about who is logged in between browser sessions? Or are you saying you store this in addition to a username and password cookie?

Sessions expire when the browser closes or after 24 minutes of inactivity. What you want are cookies. The cookie will store a unique ID/hash that points to an entry in your database with the session information.

Zorilla
Mar 23, 2005

GOING APE SPIT

duz posted:

Sessions expire when the browser closes or after 24 minutes of inactivity. What you want are cookies. The cookie will store a unique ID/hash that points to an entry in your database with the session information.

Ok, so this sounds like I actually have to create a MySQL table whose purpose is to store hashes that coordinate with remote users' cookies. Am I way off here?

Zorilla fucked around with this message at 09:25 on Apr 22, 2008

LastCaress
May 8, 2004

bonobo
Is there a way to apply an external stylesheet file to just a table? I took a stylesheet from google and applied it to a table, but it transforms the style of the whole page :| Also, does anyone want to help me with designing a PvP system? I'll give a forums upgrade. Thanks!

Zorilla
Mar 23, 2005

GOING APE SPIT

LastCaress posted:

Is there a way to apply an external stylesheet file to just a table? I took a stylesheet from google and applied it to a table, but it transforms the style of the whole page :| Also, does anyone want to help me with designing a PvP system? I'll give a forums upgrade. Thanks!

Cheap answer: put the table in a separate page and use an inline frame.

Non-nerd rage inciting answer: give the table a unique class maybe, then make modifications to the stylesheet in question so that all styles apply to elements inside that table and to nothing outside it. For instance, change:

code:
table td {
	background-color: #ccc;
}
...to...
code:
table.crap td {
	background-color: #ccc;
}

Zorilla fucked around with this message at 09:30 on Apr 22, 2008

LastCaress
May 8, 2004

bonobo
Well the stylesheet can't possibly have been made by a human unless he took massive amounts of LSD : https://www.bazul.org/rpg/pretty.css
Maybe this is overkill because I just want my table to look like this : http://www.bazul.org/rpg/battle_pvp.php?game=1 (login/pass bobin)

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


Zorilla posted:

Ok, so this sounds like I actually have to create a MySQL table whose purpose is to store hashes that coordinate with remote users' cookies. Am I way off here?

Unless you want to store sensitive information in a cookie that's readable by anyone.
The table could consist of just two columns, a session id and the serialized session data. It's really up to you how you want to do it.

Zorilla
Mar 23, 2005

GOING APE SPIT

LastCaress posted:

Well the stylesheet can't possibly have been made by a human unless he took massive amounts of LSD : https://www.bazul.org/rpg/pretty.css
Maybe this is overkill because I just want my table to look like this : http://www.bazul.org/rpg/battle_pvp.php?game=1 (login/pass bobin)

Yeah, Google optimizes the hell out of all their content, removing line breaks, spaces, and anything deemed to be dead weight. Have you seen their front page HTML? Standards compliancy be damned!

The table you linked to is using legacy color definitions to achieve the look you want anyway. In CSS, you probably just want something like this:

code:
table.myclass {	border-collapse: collpse; }
table.myclass th { color: #fff; background-color: #003399; }
table.myclass tr.username { background-color: #fff; }
table.myclass tr.password { background-color: #99ccff; }
table.myclass tr.buttons { background-color: #003399; }
table.myclass td { border: 1px solid; }

Zorilla fucked around with this message at 09:55 on Apr 22, 2008

LastCaress
May 8, 2004

bonobo
Wow I'm glad this computer thing makes sense. I did a table.css with that code and added <table summary=' ' width='95%' border='0' class='myclass'> to the php and it works! Sorry for being obtuse some times, but this is the first time I'm playing with html/php/mysql

Zorilla
Mar 23, 2005

GOING APE SPIT

LastCaress posted:

Wow I'm glad this computer thing makes sense. I did a table.css with that code and added <table summary=' ' width='95%' border='0' class='myclass'> to the php and it works! Sorry for being obtuse some times, but this is the first time I'm playing with html/php/mysql

Attributes like border= and width= are becoming deprecated. If you're going to define appearance inline, use the style= attribute, as it allows you to use the same CSS syntax you're using in your stylesheet. In your case, use something like <table class="myclass" style="width: 95%; border: none;">

That's just an example, and there aren't too many instances where you'll need to define styles inline instead of from a stylesheet, so everything I put in style="" should probably just go to table.myclass entry in your CSS.

As with anybody messing around with CSS, I recommend installing Firebug so you can see changes to CSS properties in real time. (Get 1.1 Beta; 1.0 has a bug where it won't handle <a> tags properly).

Zorilla fucked around with this message at 20:46 on Apr 22, 2008

Grigori Rasputin
Aug 21, 2000
WE DON'T NEED ROME TELLING US WHAT TO DO
I'm having a problem with strpos() that I'm not sure how best to resolve. I've got a function that cycles through a string and looks for instances of months in the format of 'mon ', i.e. 'apr ', 'may ', etc.

My problem occurs when testing for $curPos - if a month occurs at the zero position of $str, then the test will fail when ideally it will recognize a month is there for further processing.

Since zero evalutes to false, it fails even though I can tell the difference between a month that never occurs and a month at the zero position - I just can't test for it.

The only workaround I have is to concat a blank space at the beginning of $str to bump the whole thing forward one character. Any ideas how to tell the difference between a string NOT found by strpos as opposed to one found at the beginning of the string?

php:
<?php

$months = array (=> 'jan''feb''mar''apr''may''jun''jul''aug',
        'sep''oct''nov''dec');

function FindMonthPosition($str)
{
    global $months;
    
    print "$str\n";
    $curPos;
    
    foreach($months as $month)
    {
        $curPos strpos($str"$month ");

        if($curPos)
        {
            print "$month$curPos\n";
        }
        
    }
}
?>

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Grigori Rasputin posted:

Since zero evalutes to false, it fails even though I can tell the difference between a month that never occurs and a month at the zero position - I just can't test for it.

http://us3.php.net/strpos

php.net posted:

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Adbot
ADBOT LOVES YOU

Zorilla
Mar 23, 2005

GOING APE SPIT

Grigori Rasputin posted:

I'm having a problem with strpos() that I'm not sure how best to resolve. I've got a function that cycles through a string and looks for instances of months in the format of 'mon ', i.e. 'apr ', 'may ', etc.

...


PHP has powerful functionality for manipulating date and time formats. What is the end goal of this code?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply