-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
[code]
<?php
$filename = $_POST['filename'];
$newfile = fopen("/uploads/$filename.php", "x");
if($newfile){
echo "$filename.php created";
}else {
echo "failure";
}
?>
[/code]
If the file exists it wont do anything, if it doesn't PHP will try to create it. -
Thanks! Works like a charm, +karma for you, haha.
-
Very handy
-
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/marcus/public_html/admin/banip.php on line 17
The IP provided is not valid -
You could always password protect your directories, if somebody was not-lazy to actually view the image in a sep. window/tab that they couldnt access that folder
-
how would i go about checking to see if the IP given is in correct format
#dot#dot#dot# -
Do something like this:
[code]
<?php
$arra = array('aaaa','bbbb','abcd');
$var = $_GET['var']; // or whatever you what
if(in_array($var,$arra)){
echo "oky doky";
}else {
echo "no oky doky";
}
?>
[/code] -
I tried it with the separation and works now, thanks!
-
It really wouldn't matter if my table cells/data were closed or not, I'm not testing it in a doctype xhtml strict yet
-
[code]
<?php
require('../header.php');
if(!$_SESSION['admin']){
header ("Location: login.php");
}else {
$act = $_GET['act'];
$p = $_GET['p'];
$id = $_GET['id'];
if(!$act){
echo "Choose: <a href='emails.php?act=view'>View Unread</a> | <a href='emails.php?act=viewall'>View All</a>";
}else
if($act == view){
$sql = "SELECT * FROM `contact`";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "There are no pending emails at the moment!";
}else {
echo "<table border=0 cellspacing=3 cellpadding=2>\n";
echo "<tr><td style='border:1px solid #CCCCCC;'>ID<td style='border:1px solid #CCCCCC;'>Subject<td style='border:1px solid #CCCCCC;'>From<td style='border:1px solid #CCCCCC;'>Date Sent\n";
while($row = mysql_fetch_assoc($res)){
echo "<tr><td style='border:1px solid #CCCCCC;'>$row[id]<td style='border:1px solid #CCCCCC;'><a href=emails.php?act=view&p=read&id=$row[id]>$row[subject]</a><td style='border:1px solid #CCCCCC;'>$row[from]<td style='border:1px solid #CCCCCC;'>$row[date]\n";
}
echo "</table>";
mysql_free_result($res);
}
}
if($act == view && $p == read && isset($id)){
$sql = "SELECT * FROM `contact` WHERE `id` = $id";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
if(mysql_num_rows($res) == 0){
echo "This email is not available";
}else {
echo "<table border=0 cellspacing=3 cellpadding=2 width=350>\n";
echo "<tr><td style='border: 1px solid #CCCCCC;'>From: $row['from']\n";
echo "<tr><td style='border: 1px solid #CCCCCC;'>Sent: $row['date']\n";
echo "<tr><td style='border: 1px solid #CCCCCC;'>Email: $row['email']\n";
echo "<tr><td style='border: 1px solid #CCCCCC;' valign=top>Message:<br>$row['body']";
echo "<tr><td style='border: 1px solid #CCCCCC;'>\n
<a href=emails.php?act=del&id=$row['id']>Delete</a> | <a href=emails.php?act=reply&id=$row['id']>Reply</a>\n";
echo "</table>";
}
}
}
require('../footer.php');
?>
[/code]
*on 45 now -
now the same error is on line 44
-
Making a view email thingy, just keep getting the same error, can't find the problem.
[code]
<?php
require('../header.php');
if(!$_SESSION['admin']){
header ("Location: login.php");
}else {
$act = $_GET['act'];
$p = $_GET['p'];
if(!$act){
echo "Choose: <a href='emails.php?act=view'>View Unread</a> | <a href='emails.php?act=viewall'>View All</a>";
}else
if($act == view){
$sql = "SELECT * FROM `contact`";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "There are no pending emails at the moment!";
}else {
echo "<table border=0 cellspacing=3 cellpadding=2>\n";
echo "<tr><td style='border:1px solid #CCCCCC;'>ID<td style='border:1px solid #CCCCCC;'>Subject<td style='border:1px solid #CCCCCC;'>From<td style='border:1px solid #CCCCCC;'>Date Sent\n";
while($row = mysql_fetch_assoc($res)){
echo "<tr><td style='border:1px solid #CCCCCC;'>$row[id]<td style='border:1px solid #CCCCCC;'><a href=emails.php?act=view&p=read&id=$row[id]>$row[subject]</a><td style='border:1px solid #CCCCCC;'>$row[from]<td style='border:1px solid #CCCCCC;'>$row[date]\n";
}
echo "</table>";
mysql_free_result($res);
}
}
if($act == view && $p == read && isset($_GET['id'])){
$sql = "SELECT * FROM `contact` WHERE id =$_GET['id']";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
if(mysql_num_rows($res) == 0){
echo "This email is not available";
}else {
echo "<table border=0 cellspacing=3 cellpadding=2 width=350>\n";
echo "<tr><td style='border: 1px solid #CCCCCC;'>From: $row['from']\n";
echo "<tr><td style='border: 1px solid #CCCCCC;'>Sent: $row['date']\n";
echo "<tr><td style='border: 1px solid #CCCCCC;'>Email: $row['email']\n";
echo "<tr><td style='border: 1px solid #CCCCCC;' valign=top>Message:<br>$row['body']";
echo "<tr><td style='border: 1px solid #CCCCCC;'>\n
<a href=emails.php?act=del&id=$row['id']>Delete</a> | <a href=emails.php?act=reply&id=$row['id']>Reply</a>\n";
echo "</table>";
}
}
}
require('../footer.php');
?>
[/code]
error:
[code]
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/marcus/public_html/admin/emails.php on line 35
[/code] -
Thanks, it works :D
-
So $num * ($percent/100) ?
-
i just started trying to learn basic function work
[code]
<?php
function percent($num,$percent){
if(isset($num) && isset($percent)){
$math = $num * 0.$percent;
echo "$percent% of $num is $math";
}else {
echo "A number and percent must be valid!";
}
}
percent(10,30);
?>
[/code]
I get:
[code]
Parse error: parse error, unexpected T_VARIABLE in C:\Documents and Settings\Owner\Desktop\xampp\htdocs\testing\1a\i2.php on line 7
[/code]
I have tried double quotes but it just echoed it off. -
No problem :D
-
well for one, the fourth to last line is wrong, you need to end the query first then comma then $connection.
and is AS even part of the SQL Syntax? -
please
-
The whole code looks fine
[code]
if($teams == 1)
{
$player0team = $_POST['player0team'];
//determining if player 0 already has stats listed for this match/round/court
$player0_team_modifyoradd = mysql_query("SELECT LA4square_team_stats.TStatsPlayerNum AS teamplayerid
FROM LA4square_team_stats
WHERE LA4square_team_stats.TStatsPlayerNum = $player0num AND
LA4square_team_stats.TStatsTeamID = $player0team AND
LA4square_team_stats.TStatsSeasonID = $season_id AND
LA4square_team_stats.TStatsMatchID = $matchid AND
LA4square_team_stats.TStatsMatchRound = '$rounds_select' AND
LA4square_team_stats.TStatsMatchCourt = '$courts_select'", $connection) or die(mysql_error());
if(mysql_num_rows($player0_team_modifyoradd) == 0)
{
[/code] -
Oh, you should have said that :P
-
You never ended the first if statement
[code]
if($teams == "1")
{
$player0team = $_POST['player0team'];
//determining if player 0 already has stats listed for this match/round/court
$player0_team_modifyoradd = mysql_query("SELECT LA4square_team_stats.TStatsPlayerNum AS teamplayerid
FROM LA4square_team_stats
WHERE LA4square_team_stats.TStatsPlayerNum = '$player0num' AND
LA4square_team_stats.TStatsTeamID = '$player0team' AND
LA4square_team_stats.TStatsSeasonID = '$season_id' AND
LA4square_team_stats.TStatsMatchID = '$matchid' AND
LA4square_team_stats.TStatsMatchRound = '$rounds_select' AND
LA4square_team_stats.TStatsMatchCourt = '$courts_select'", $connection)
or die(mysql_error());
}
if(mysql_num_rows($player0_team_modifyoradd) == 0)
{
[/code] -
I assume, but some people don't like taking that extra step and typing the dot.
-
replace DISTICT with DISTINCT
-
You could just do
[code]
mkdir("artwork/$newdir");
[/code]
posting form data to two php scripts at once
in PHP Coding Help
Posted
[code=php:0]
<?php
include('second.php');
?>
[/code]