On our way....
V-P
State College, PA Member
Well, my thinkquest team is finally doing work, thanks to air. Me, air, ParanoidIronMan, and 3 other friends are finally getting down to business, and we have a nice layout so far. We decided not to do a full flash site, but rather, just make the menu's, navigation, etc flash in the html site. I will post a link or a pic or something later on through the project, when it's safe from being stolen. Thanks Air!
P.S, I recieved your info PM, and it's saved in my inbox, and I'll give it to the coach as soon as school starts, and if you have a fax, PM the number so I can send it to you, since my scanner doesn't want to work, and mail takes too long.
P.S, I recieved your info PM, and it's saved in my inbox, and I'll give it to the coach as soon as school starts, and if you have a fax, PM the number so I can send it to you, since my scanner doesn't want to work, and mail takes too long.
0
Comments
Ok, on another topic, I have some php problems. I am trying to make a little app so that we can submit work that we have done, and also work that needs to be done. but I have some problems with the code. I am uploading a zip with all of the files in it, and I am going to put this online also, so that you can see the errors that it is throwing when I try to submit the form, which adds entries to a table in the database. I'm sending data for about 14 fields I think. anyway, Im at a loss. I tried to find the error, I know this thing is far from secure, but it doesnt need to be secure, just useable. not to mention, i dont know how to code a user management system, nor do I want to for something as simple as this.
here is what it say:
I've looked at the lines it says, and those are the lines where I assign the posted value to a variable, then it goes through the script. The thing is, it only does that on some of the assignments, not all of them.. and I am at a loss.
slower
Don't use spaces (or use underscores _) in the form input feilds. Fix all of them using the following way:
[PHP]<input type="text" name="requestedby">
...
$by = $_POST["requestedby"];[/PHP]
The database isnt throwing any errors or anything, but when I go to the page to view all of the current requests, "requests.php", it displays nothing. it is making me wonder if the values are actually getting into the database, because I have an if statement to check if any values are returned, and if there arent any, it is supposed to display a message that says none were found, and that is what it is displaying..
[PHP]<?php
//include connection data
include("dbconnect.php"); ?>
<?php
//select the needed data form the db
$sql="SELECT * FROM requests order by id DESC";
$result=mysql_query($sql);
if(mysql_num_rows($result) == 0){
//If there are no requests, tell the visitor
echo("<span class='style1'>There are no requests. Make a request</span> <a href='request.php'> here</a>");
}
?>
<link href="styles.css" rel="stylesheet" type="text/css" />
<table align="center" width="850" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table align="center" width="850" border="0" cellspacing="2" cellpadding="3">
<tr>
<td width="185" align="center" class="box_button"><div align="left">Requested From</div></td>
<td width="564" align="center" class="box_button"><div align="left">Short Description</div></td>
<td width="75" align="center" class="box_button"><div align="left">Done?</div></td>
</tr>
<?php
//Display the requests, including who submitted it, why, and its status.
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center" class="style1"><? echo $rows; ?></td>
<td align="center" class="style1"><? echo $rows; ?></td>
<td align="center" class="style1"><img src="images/<? echo $rows; ?>.jpg" /></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<div align="center"><a href="admin.php">Admin panel</a> <span class="style1">|</span> <a href="request.php">Request a song</a></div>[/PHP]
Re-structure the IF/THEN statements. As it stands now, if zero results are returned it displays the error but still goes through the WHILE to display the results that don't exist. Add an ELSE to display the results in.
There's no sore thumb sticking out in the code you posted now. I believe it's possibly the INSERT code in request.php (line 25):
Note the extra "," inside your INSERT. That may be tripping it up. Also using VALUES ('{$by}',... helps PHP find the variables. It's good practice because you can be sure they'll be substituted for their value whereas leaving it how it is now isn't always a guarantee.
Note: Make sure if the CODE is being judge, filter out the supplied content before putting it in SQL. I could put an invalid "needby" to make it execute my own SQL. Possible your whole DB could be dropped.
I have a place in the admin page for incomlete requests, and complete requests.
in the incomplete requests, I need it to display results from two different queies in it.
would it be:
$sql="SELECT * FROM requests WHERE status='0' or SELECT * FROM requests WHERE status='1'" ;
[PHP]SELECT * FROM requests WHERE status = '0' UNION ALL SELECT * FROM requests WHERE status = '1'[/PHP]
I assume there are more than 2 states for 'status' or you'd be taking a long way to select everything.
0, 1, and 2.
0 is new
1 is in progress
2 is completed.
so I have to categories, unfinished and finished, I want 0 and 1 in unfinished, and 2 in finished.
is there a better way?
by the way, you are being a HUGE HELP right now!
//include connection data
include("dbconnect.php"); ?>
<?php
//select the needed data form the db
$sql="SELECT * FROM requests order by id DESC";
$result=mysql_query($sql);
if(mysql_num_rows($result) == 0){
//If there are no requests, tell the visitor
echo("<span class='style1'><b>There Are No Requests.<b></span><br /> <a href='request.php'>Make a Request Here</a>");
die;
}else{
?>
<link href="styles.css" rel="stylesheet" type="text/css" />
<table align="center" width="850" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table align="center" width="850" border="0" cellspacing="2" cellpadding="3">
<tr>
<td width="185" align="center" class="box_button"><div align="left">Requested From:</div></td>
<td width="564" align="center" class="box_button"><div align="left">Short Description:</div></td>
<td width="75" align="center" class="box_button"><div align="left">Statu:</div></td>
</tr>
<?php
//Display the requests, including who submitted it, why, and its status.
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center" class="style1"><? echo $rows; ?></td>
<td align="center" class="style1"><? echo $rows; ?></td>
<td align="center" class="style1"><img src="images/<? echo $rows; ?>.jpg" /></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<div align="center"><a href="admin.php">Admin panel</a> <span class="style1">|</span> <a href="request.php">Make A Request</a></div>[/PHP]
I tried to re arange the if/then statement, and I got myself some parse errors. Im not that good in debuggin php, as I am largely still a beginner in it. all the php tags open and close, and I dont know what else to check for. Im reading my php book. So I guess I am pulling a shorty, though he new more of what he was doing. this is all proceduraly (thank god) except for the dbconnect. because all of what I have done is procedural, this year we get too learn oop.
[php]<?php
//include connection data
include("dbconnect.php"); ?>
<?php
//select the needed data form the db
$sql="SELECT * FROM requests order by id DESC";
$result=mysql_query($sql);
if(mysql_num_rows($result) == 0){
//If there are no requests, tell the visitor
echo "<span class='style1'><b>There Are No Requests.<b></span> <a href='request.php'>Make a Request Here</a>";
die;
}else{
?>
<link href="styles.css" rel="stylesheet" type="text/css" />
<table align="center" width="850" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table align="center" width="850" border="0" cellspacing="2" cellpadding="3">
<tr>
<td width="185" align="center" class="box_button"><div align="left">Requested From:</div></td>
<td width="564" align="center" class="box_button"><div align="left">Short Description:</div></td>
<td width="75" align="center" class="box_button"><div align="left">Statu:</div></td>
</tr>
<?php
//Display the requests, including who submitted it, why, and its status.
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center" class="style1"><? echo $rows; ?></td>
<td align="center" class="style1"><? echo $rows; ?></td>
<td align="center" class="style1"><img src="images/<? echo $rows; ?>.jpg" /></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
}
?>
<div align="center"><a href="admin.php">Admin panel</a> <span class="style1">|</span> <a href="request.php">Make A Request</a></div>[/php]
1) Prime, can I link directly to SM or use your RSS feeds?
2) If I can, how would I make flash update some dynamic text boxes according to the RSS feeds, which would include the title written in the textbox, and then automatically update the link according to SM, or whatever site I use.
my hero.
hey, I just thought of somehting, does sql have a != operator? so instead of unioning them together, I could have just said != 2
thats my future job your burning down there
I have a page to edit entries, and everything works fine, except for the drop down menus.
I have drop downs to select the date, as well as am/pm for the time. and when I want to call those values back into the edit page, as far as i know, you cant do that with drop downs.
so this is what I figured out, and I think that there has to be an easier way.
[PHP]<? if ( $rows == "1" ) {
echo "selected value=\"1\""; } ?>[/PHP]
if I do that, I would have to set both values for each one, and that seems redundant to me. I wish there was a way that I could put up in the main select tag that went like
[PHP]<select size="10" selected value ="<? echo $rows; ?>" >[/PHP]
that would be so much easier...
[PHP]function stamp2combos ($timestamp) {
// Check if there is a timestamp supplied. If not, use current time
if ( $timestamp == "" ) {
$timestamp = time();
}
// Start string that will be returned.
$end_str = "";
$month = date( "F" , $timestamp );
$month_num = date( "n" , $timestamp );
$day = date( "d" , $timestamp );
$year = date( "Y" , $timestamp );
$hour = date("g", $timestamp);
$minute = date("i", $timestamp);
$ampm = date("A", $timestamp);
// MONTHS
$end_str .= "\t<select name=\"month\" id=\"month\">\n";
for ($i = 1; $i <= 12; $i++) {
if ( $i == $month_num ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("F", mktime(0,0,0,$i,1,$year)) . "</option>\n";
}
// DAYS
// YEAR
// HOURS
// MINUTES
// AM/PM
return $end_str;
}
[/PHP]See if you can finish it. It needs the "days", "years", "hours","minutes", "am/pm" sections. All follow the same structure as months, just change the details.
You want to learn? You're gonna learn
I have a fews ?'s though.
[PHP]$end_str .= "\t<select name=\"month\" id=\"month\">\n";
for ($i = 1; $i <= 12; $i++) {
if ( $i == $month_num ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("F", mktime(0,0,0,$i,1,$year)) . "</option>\n";
} [/PHP]
I see that you are concatenating the lower string, but how come you put the . before the assignment operator?
and I shouldnt have a problem with re-using the $end_str var, as it will never need to be recalled after it is used for each field, right?
[php]$comboHTML = stamp2combos($rows); // $comboHTML contains the HTML of the combo boxes[/php]
2) Using ".=" appends (adds to the end) of a variable. It is the same as $endstr = $endstr . "add to end";
$x = $x . $y
I get it now. I went through, and I think I get it, but I think there might be a few probs, especially the am/pm selection.
[PHP]<?
function stamp2combos ($timestamp) {
// Check if there is a timestamp supplied. If not, use current time
if ( $timestamp == "" ) {
$timestamp = time();
}
// Start string that will be returned.
$end_str = "";
$month = date( "F" , $timestamp );
$month_num = date( "n" , $timestamp );
$day = date( "d" , $timestamp );
$year = date( "Y" , $timestamp );
$hour = date("g", $timestamp);
$minute = date("i", $timestamp);
$ampm = date("A", $timestamp);
// MONTHS
$end_str .= "\t<select name=\"month\" id=\"month\">\n";
for ($i = 1; $i <= 12; $i++) {
if ( $i == $month_num ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("n", mktime(0,0,0,$i,1,$year)) . "</option>\n";
}
// DAYS
$end_str .= "\t<select name=\"day\" id=\"day\">\n";
for ($i = 1; $i <= 31; $i++) {
if ( $i == $day ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("d", mktime(0,0,0,$i,1,$year)) . "</option>\n";
}
// YEAR
$end_str .= "\t<select name=\"year\" id=\"year\">\n";
for ($i = 2006; $i <= 2020; $i++) {
if ( $i == $year ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("Y", mktime(0,0,0,$i,1,$year)) . "</option>\n";
}
// HOURS
$end_str .= "\t<select name=\"hours\" id=\"hours\">\n";
for ($i = 1; $i <= 12; $i++) {
if ( $i == $hour ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("g", mktime(0,0,0,$i,1,$year)) . "</option>\n";
}
// MINUTES
$end_str .= "\t<select name=\"minutes\" id=\"minutes\">\n";
for ($i = 1; $i <= 60; $i++) {
if ( $i == $minute ) {
$selected = "selected";
} else {
$selected = "";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("i", mktime(0,0,0,$i,1,$year)) . "</option>\n";
}
// AM/PM
$end_str .= "\t<select name=\"ampm\" id=\"ampm\">\n";
if ( $ampm == "am" ) {
$i = "am";
} else {
$i = "pm";
}
$end_str .= "\t\t<option value=\"". $i ."\" ". $selected .">" . date ("i", mktime(0,0,0,$i,1,$year)) . "</option>\n";
return $end_str;
}
?>[/PHP]
Keebs, if the RSS feeds get back up, would it be possible to to just grab the feeds from the news threads.
V|P, do you not have control of the servers? Most people think of databases when Oracle is mentioned. Do you mean the DB (which would have nothing to do with PHP/Perl/etc) or Oracle HTTP? (which does support PHP when enabled. It's based of Apache HTTP) In a competition I think it would be ignorant to only allow static content that doesn't interact or 'wow' anyone, it just sits there.
Learn some JavaScript. There are enormous amounts of scripting sites dedicated to JavaScript which most are free. Get an idea of something to do and look for examples. Don't copy some one's code but take key features and make something new. I created a "MP3 DJ" application that heavily uses JavaScript to work and it's like nothing I've seen before on the web. Couldn't do it without JS.