ryantroop 177 Practically a Master Poster

For the record, you have TONS of these all over the place... it will take you a while to find them all, I fear... I would go through line by line and fix them as you come across them.

ryantroop 177 Practically a Master Poster

$uploadResponse = "File Upload Complete!<br /> The file has been saved as ¥".$_REQUEST['listname']."¥ and will be displayed as ¥".$listnameNice."¥<br /><br />";

proper formatting for concatenation is:
$var = "my string starts here and I will only use one quote to break it ".$add_this_var." and now I can continue with my string. If I want to use an array I have a few options, but the easiest is to ".$myarray['use_this_method']."and notice the single quotes.";

Line 59 is formatted correctly, but I think the error is coming from line 51, having the same format error of using "" after a .

Good luck!

Ryan

ryantroop 177 Practically a Master Poster

ugh, sorry.. use implode(', ', $_POST['myvariabel']);

join is depreciated.

And so youre clear on what will be happening, when you are all done with that you will end up with the string:

Games picked: A, B

and that string would have been stored in $lettersIwant

ryantroop 177 Practically a Master Poster

I think what you want is a checkbox, not a radio button. Only 1 radio may be picked per form, per name (Right now, all of your radios have the name "What game modes do you play"

If you change those to check boxes you can pick multiples, and they will end up stored in an array (this makes a 2 dimensional array within POST. Ill explain).

So, lets just make a 2 checkbox form, and how to handle it.

<form action='myphp.php' method='post'>
<input type='checkbox' name='myvariable[]' value='A' />My Label A<br />
<input type='checkbox' name='myvariable[]' value='B' />My Label B<br />
<input type='submit' value='Send'>
</form>

Notice the [] after the name.


Lets say I do 3 attempts with this script.
attempt 1: no boxes checked
attempt 2: only Value A is checked
attempt 3: Both are checked.

Attempt 1:
$_POST['myvariable'] is unset. There are no values, and it cannot be accessed.

Attempt 2:
$_POST['myvariable'] == 'A' <- the only option selected. This may or may not work.
Alternatively, we can do:
$_POST['myvariable'][0] == 'A' as this is still a 2 dimensional array. Same way of calling it, but more direct, and in our case more "proper."

Attempt 3:
$_POST['myvariable'] will result in "Array" because it has an array stored at it's location. We have a 2 dimensional array and need to treat it as such.

$_POST['myvariable'][0] == 'A'
$_POST['myvariable'][1] == 'B'


So, how do we use this information?

In your case, you want people to show what kinds of games they play, …
ryantroop 177 Practically a Master Poster

ok.. so if Im following along with you right ->
You're pulling stock numbers from a database.
Those stock numbers are individually posted on your page for ordering purposes.

If that is correct, you have two options.

Do the math in the database
"SELECT col1, col2, (SELECT SUM(col1, col2)) as total FROM mytable WHERE boxcolor='whatever';"

Do the math after the database

while($data = mysql_fetch_object($result)) {
$total = $data->col1 + $data->col2;

}

Is that what you're looking for?

Ryan

logicaweb commented: I right now wanted to write something like this, but you're faster! +0
ryantroop 177 Practically a Master Poster

Line 22: $membershipField (as per your assigned variable above)
In fact.. looks like all your variables need to changed other than Mic :-P

you need to use the same variable names you assigned.

so.. like the one I pointed out -
Line 11: $micField = $_POST['mic'];
Line 22: Microphone: $micField;

However, for line 10, 20:
Line 10: $gtField = $_POST['gt'];
Line 20: Gamertag: $gt; //this is a mismatch

Good luck!

Ryan

As for your other question - I do not think that radio buttons need labels (none of them do, really, but it's fine if you use them. However, you are putting a null label in for the radios so.. they are a bit useless.).

ryantroop 177 Practically a Master Poster

Assuming your form has the names right from the HTML submitting page...

try capitalizing POST so $_POST['gt']

Im pretty sure globals are case sensitive.

ryantroop 177 Practically a Master Poster

Im trying to do this independent of twisted, or any other framework. However, it may be a good starting point. My appologies for not being clear.

ryantroop 177 Practically a Master Poster

So, I would like to start working on a python module to support RFC 2326 (RTSP), in an effort to work on a larger application that I will probably need help with later.

I am unsure how to go about making software that is meant to adhere to a specific RFC, and Im looking for guidance on getting started..

Would I start with a socket, and expand from there? How do I manage all the possible media types? Is that a part of the RFC or is that separate? I have read through the RFC once (and understood most of what it is saying), but I am unsure how to implement something that works in the frame set by the RFC. Is it simply a socket and a set of commands that meet the commands of the RFC? Or is the software supposed to handle all those commands? If that is the case, then does the software need to interact with the host by splitting up the data, and handling the trash?

I want to do the work, but I need a push in the right direction on where to start. Any suggestions?

-- Alternatively, do I really need to adhere to an RFC to make something work? If I plan on making a program that chunks video and does something with it while streaming, does it HAVE to work as RFC indicates?
(Now, I understand that the people who write these things are generally very well educated. I …

ryantroop 177 Practically a Master Poster

Youre welcome :)

ryantroop 177 Practically a Master Poster

delete the closing bracket on line 35 and i think youre good.

ryantroop 177 Practically a Master Poster

Look at your code very carefully, like lines 36, 39, and 46, and see if you formatted things correctly. Is the else followed by a {

ryantroop 177 Practically a Master Poster

There is nothing wrong with the redirect. If you take out the if check on the page being redirected to, you will have the page load just fine. The problem is your sessions are not persisting through your domain.

ryantroop 177 Practically a Master Poster

the proper syntax for else is:

else { ... } <- you need open and closing brackets just like an if statement.

ryantroop 177 Practically a Master Poster

The first paragraph here will help get you started:
http://docs.python.org/py3k/library/turtle.html

This will help understand triangles:
http://www.freemathhelp.com/feliz-angles-triangle.html

The key part is understanding that all triangles will have a total of 180* as the sum of all angles. That means, given your 3 inputs, if they don't add up to 180* then it's not a triangle.

You have a lot of choices on how to start. A better way for us to help you is to start writing some code, and when you have trouble or get stuck, then ask. Homework is meant for you to learn, not for people on a message board to do it for you.

ryantroop 177 Practically a Master Poster

Nothing wrong with using both.

What is the problem you are having?

ryantroop 177 Practically a Master Poster

I made a type on line 2. Should read if(!isset(session_id())){ <- note the extra parentheses.

I really don't know why you are having trouble with this... Ill keep looking on the googlefriend...

ryantroop 177 Practically a Master Poster

Sorry, not sure why that happened.. if you copy and pasted directly I missed two parentheses.

should be:

if(isset($_POST['key'])){
$key = $_POST['key'];
$sql = "SELECT * FROM user WHERE name like '%$key%';";
....
}
ryantroop 177 Practically a Master Poster

k.. I think I got it.

on workspace_files.php do this and delete what you have:

<?php
if(!isset(session_id()){
header('Location: workspace.php');
exit();
}else {
if(isset($_SESSION['username'])) {
?>

YOUR HTML HERE


<?

}else { // no session and no user so someone accessed the page improperly
header('Location: workspace.php');
exit();
}
?>

Explanation: If your server has session.autostart enabled in php.ini (which I think it does) then sessions will persist automatically between your pages. When we call session start, if this setting is enabled, we are basically overwriting the current session, and losing all our data.

If the above works, it means that the setting is enabled. Instead, on your pages you need to see if a session_id() is set, and if so then a session is initiated, and we dont need to set another one.

ryantroop 177 Practically a Master Poster

on a new page try this:

<?php
if(session_start()) {
echo "I started!";
}
else{
echo "I didn't start :(";
}
?>
ryantroop 177 Practically a Master Poster

well that is quite odd..

do you know how to set permissions for your folders?

If you can, make sure your HTML root folder has read and write priveleges.

If you use file-zilla (it's the only way I know how to do it), right click on the folder that your index.php is (the folder, not the file), and set the number in there to 777. See if that helps.

ryantroop 177 Practically a Master Poster

with internet explorer, you click the cog looking thing, go to internet settings -> (under history) settings -> view files

if there are a lot of them, you need to clear them out (delete them) and then try to run your script.

ryantroop 177 Practically a Master Poster

did the cookie set in your cookies folder?

ryantroop 177 Practically a Master Poster

do me a favor and clear out all your cookies. Close your browser, open and retry it. Make sure you are getting a cookie set.

Also, apparently an oddity, check to see if it works in another browser.

ryantroop 177 Practically a Master Poster

to fix the code I gave you, add another } to line 34. The rest is fine.

and.. after review... it seems that you forgot session_start() at the top of your page again ;) That should fix your problem.

ryantroop 177 Practically a Master Poster

same 'result' we had last night :-P

ryantroop 177 Practically a Master Poster
if(isset($_POST['key']{
$key = $_POST['key'];
$sql = "SELECT * FROM user WHEN name LIKE '{%$key%}'";
....

you probably dont even need the {} and you may want to escape $key before you pop it in your query.

ryantroop 177 Practically a Master Poster

woops.. line 28 add another closing )

while ($data = mysql_fetch_array($result)) {
ryantroop 177 Practically a Master Poster
ryantroop 177 Practically a Master Poster

would need to see the code to see what you are trying to accomplish.

ryantroop 177 Practically a Master Poster

from line 38 change as follows:

while ($data = mysql_fetch_array($result) {
 $redirect = trim($data['redirect']);
 if($redirect == '') {
  echo "No redirect value found!";
 }else {
 header("Location: $redirect");
 exit();
}
}
else {
header ("Location: workspace.php");
exit();
}
?>
ryantroop 177 Practically a Master Poster

k, remove session_write_close();

Im betting the missing exit() was the problem. Should work with that gone.

ryantroop 177 Practically a Master Poster

after line 50 you need exit(); as well. any header change requires a complete exit(); from the script.

ryantroop 177 Practically a Master Poster

Zagga, if you look up you will see that the redirects are working. I forgot that we tested it last night and he said we got a message from the target page. The problem is with $_SESSION persistence.

instead, in workspace_login.php, before the header redirect (line 36), add session_write_close();

Also, I think exit on line 37 should be exit();

ryantroop 177 Practically a Master Poster

gaaaaaaah!!!

I assumed the directory was saved in the database, and not just the page name... facepalm

try:
header("Location: /$redirect");

if you are on a Windows server it may be:

header("Location: \$redirect");

and if all else fails...

header("Location: ./$redirect"); <- notice the period. If one period doesnt work, you can always try 2 ../

ryantroop 177 Practically a Master Poster

Ok.. so this is a basic structure that should get you going in the right direction (I hope).

<?php
$usr = 'sqlusr';
$pw = 'sqlpw';
$host = 'sqlhost';

$db = mysql_connect($host, $usr, $pw);
mysql_select_db('dbname');

$nordem = $_POST['nordem'];
$nordem = mysql_real_escape_string($nordem);

$query = "SELECT * FROM entrada WHERE nodem_n = '$nordem';";
$result = mysql_query($query);

while ($data = mysql_fetch_object($data)) {
?>
<table><form action='mypage.php' method='post'>
<tr>
 <td>Field 1</td><td>Field 2</td><td>Field 3</td>
</tr>
<tr>
 <td><? $data->col1; ?></td><td><? $data->col2; ?></td><td><? $data->col3; ?></td>
</tr>
<tr>
 <td><input type='submit' value='submit'></td><td><input type='hidden' name='id' value='<? $data->id; ?>'></td>
</tr>
</form>
</table>
<?
}
?>

Now, lets assume that there is only 1 entry, we should only get 1 form back. This is completely bare bones, and has no functionality other than sending a blank post to mypage.php.

For reference.. instead of making an array, I made an object called $data. Inside data, all the columns are stored by keyname. So, $data->id will give the value of the id column in your sql table.

Now, we can further configure our form, to make our default value of a text field.. so lets say we were doing 'Field 1' value...

on the next row, the first <td></td> we would put

<td><input type='textbox' name='whatever' value='<? data->whatever ?>'></td>

Then, when we hit submit, we now have a POST value of 'whatever' being sent to our mypage.php

Then, on mypage.php we can do something with it.

<? if(isset($_POST['whatever']){
//run some program/do sql query or update or whatever
}
?>

That's it... you will notice …

ryantroop 177 Practically a Master Poster

ok, first - no matter how many <? ?> you have on your page, you only need to connect once. Ideally in the original <?php .... ?> pair, but it persists on the page as a whole, regardless of embedded HTML.

line 68, 69, 71 - You are doing the same operation twice, and in fact you are ignoring data.
$num = mysql_num_rows($query); // this is meant to check the number of rows returned. That's it!

so if by calling that, and then checking if(!$result) {} you essentially just asked if anything was there, assign that number to $num. If something is there, then do something. And then you forget about $num.

it is usually used as:

$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num > 0) { //run my script } else { //oops! No data! }

Now, as for the rest of what you have going on.. I think you need to be a little more clear.

Are you having trouble with your data displaying properly? Or is it not updating properly with the 2nd page?

ryantroop 177 Practically a Master Poster

Sorry I couldnt help more... goodnight :)

ryantroop 177 Practically a Master Poster

Primary refers to it being a primary key, which means it is the first column checked against when relating to other tables, when running joined queries.

Default is the default value given, assuming that no data is passed to it when a row is created.

Please keep in mind that you should be hashing your passwords when they are stored in a database. They should be hashed in PHP, then stored as a varchar(8/16/32) depending on the hash type you use.

Passwords are not meant to be saved as plain text in a database. Imagine getting hacked, and all your users will have their passwords exposed. Always try to make it one step harder if you can.

However, before you even get there, we need to get you a working page.

ryantroop 177 Practically a Master Poster

You can embed a bunch of includes on the main login page, and have it parse to itself.

so...

<?php
if(!isset($_POST) || !isset($_SESSION)){ ?>    //if neither POST or SESSION is set, show form
show your table here with html
<?
}else {

if ($_POST['username']) {
//run script to validate

//if invalid, redirect or error message. Your choice.

//if valid, session_start()
//$_SESSION['username'] = $_POST['username'];
}

if(isset($_SESSION['username'])) {
//determine what page to include as $page_to_include

if($page_to_include == 1) {
include_once('page1.php');
}
else if ($page_to_include == 2) {
include_once('page2.php');

}

.... etc... etc...




}
?>
ryantroop 177 Practically a Master Poster

k.. you can get rid of the die()... I have no idea why it isnt going through....

Just to be clear, it is the right username? You have $username declared twice, which is why I pointed it out earlier... it's the only thing I can think of that is causing the problem.. but your query goes through... which means the POST is not overwriting it... so I really don't know :(

I still suggest changing the first $username to $user and changing the mysql_connect() to use $user as well... if not that, I dont know.

ryantroop 177 Practically a Master Poster

you will need to eventually add exit(); after a header() call, so put that in because it belongs there.

on line 33 of login page, put die("$username");

ryantroop 177 Practically a Master Poster

on line 34 of login, try chaging it to:

$_SESSION['username'] = $_POST['username'];

ryantroop 177 Practically a Master Poster

Your sessions are not staying persistent... interesting.

Make a new page, and put <?php phpinfo() ?>

and see what version you are running (you can use cntl+f and search version), and see if you have global_vars (search global) turned on or off.

Im guessing youre running PHP4 and you need to use HTTP_SESSION_VARS[] instead of $_SESSION[] but we wont know until you tell us the version.

ryantroop 177 Practically a Master Poster

Try this first, at the top of workspace_files.php:

session_start();
$nm = $_SESSION['username'];
exit("The username in this session is $nm.");

If you get "empty" or "Null" or "The username in this session is ." Then you have a whole different problem to handle.

Then we can try below if necessary.
I kinda wrote this backwards, as I thought of the above after I wrote the below.

Correct me if Im wrong, but shouldn't it just be:

if(!$_SESSION['username']) {
}

instead of using isset()... seems a bit redundant, and may be what is causing the error...

Alternatively, though unlikely, global variables may be turned on in your particular configuration, and if you are using mysql on each of your pages (importing, whatever), you may be overwriting the $username variable from your mysql loging.

Consider changing either $username to $usrnm and change all calls to it --
mysql_connect($host, $usr, $pw);

Alternatively, you can change all your session variables from $_SESSION['username'] to $_SESSION['usr'];

Whichever will save you more typing.. shrug

Ryan

ryantroop 177 Practically a Master Poster

without knowing the context of DEBUG CODE it's hard to say exactly what it is... it is either a build it command for developers to see particular errors, or it's a left over from when they were actually debugging... hard to say.

ryantroop 177 Practically a Master Poster

You would do well to understand what SESSIONS are COOKIES are, and how to use them. Basically, as you are using them, a permission file is a php page that can be accessed when the user is logged in, and their session data is available to the server.

Sessions are pretty simple.

To start them, you simply add:
session_start(); to the top of any page where a user will need to have persistent data available to the page.

As for logins, you can do a form/whatever flavor of validation you want, and then after you call session_start(); you can populate sessions as you would any array.

session_start()
$_SESSION['user'] = "LastMitch";

Now, any time that a user accesses a page on my server, from my http root, as long as there is a session_start() as the first line (some rules are meant to be broken) of PHP code on the page (preferrably before any code, even HTML), I can access my global (that's what $_ is for) variable $_SESSION[].

To destroy, or end a session, you can either close your browser and it should end automatically. Or, you can manually do it by unsetting/destroying the session.

if($_GET['end_session'] == "True") {
session_unset(); //remove all session data, but leave persistence
unset($_SESSION['user']); //alternatively we can unset a specific variable in the array.
session_destroy(); //in either case, we want to remove persistence, and end the session completely.
}

In the particular snippet above, it is saying:

    if(!$_SESSION[""]) {      //if no session …
LastMitch commented: Thanks for the link & the simple example & explanation! +0
ryantroop 177 Practically a Master Poster

get rid of the concatenation...

mysql_query("UPDATE member_info SET tel='33333339' where id='$update_id';");

You can do inline variables, as long as you are using " " instead of ' '.

In your particular case, however, it looks like you have double quotes twice at the end of your statement, which basically ruins the string as a whole.

I would encourage you, though, to chage it further and do:

$my_string = "UPDATE member_info SET tel='33333339' where id='$udpate_id';");
$my_string = mysql_real_escape_string($my_string);
mysql_query($my_string)
ryantroop 177 Practically a Master Poster

If it were me doing this, it wouldn't be too terribly different, it would just be shorter and a bit more readable. On top of that, I would sanitize my queries and control type setting from the user, so that someone couldnt pass '$10000' when theyre supposed to be putting in their address. Also, allowing $_POST to be placed directly in your query allows hackers/stupid people to send a query to either get all info from your table, or worse destroy your table. I also don't know how your SQL tables were set up, nor what permissions you allow for the user.

That said, your whole project could be done with a single PHP page. There is no need to spread it out over so many, but I understand that compartmentalizing the way you are helps to keep references and purpose to each page. That's a style issue more than a "this is the best way."

Lastly, I would probably break up all these into functions and import the repetetive connection data as necessary. For future reference, look into how .htaccess is configured with PHP (so you can create a protected directory), and how you can store passwords, database names, encryption keys, functions, and other includes that you don't want made available to the public, in a directory that is not accessable from outside the server or root FTP access.

As for the problem you are encountering --
I've personally never encountered the error you are getting. Google seems …

ryantroop 177 Practically a Master Poster

The first lines are nothing major. If you can configure your server to disable error reporting, they will go away. Again, it comes down to your code being "ugly" and the parser is very unhappy with you. (Unless someone else knows something I dont).

The second problem... which file is update.php?

It seems you have a bad query somewhere else...