Scottmandoo 0 Junior Poster in Training

Thank you, i defined $email instead of $user. Sorry its been a long night, lucky i had some fresh eyes to go over my code

Scottmandoo 0 Junior Poster in Training

This is what i got

"
5
13

Notice: Undefined variable: user in [urlgoeshere] on line 16
"

Scottmandoo 0 Junior Poster in Training

in the below code, everything works. However if the user is logged in (where is says html goes here) it wont display anything at all.

<?php 
// Connects to your Database 
mysql_connect('host', "user", "password") or die(mysql_error()); 
mysql_select_db("database") or die(mysql_error()); 

//checks cookies to make sure they are logged in 
if(isset($_COOKIE['ID_']))
{
$email = $_COOKIE['ID_']; 
$pass = $_COOKIE['Key_'];
$check = mysql_query("SELECT * FROM users WHERE username = '$user'")or die(mysql_error());
while($info = mysql_fetch_array( $check )) 
{

//if the cookie has the wrong password, they are taken to the login page 
if ($pass != $info['password']) 
{ echo "<center><a href='index.php'>Invalid Password! Please Click Here to Log In</a></center>"; 
} 

//otherwise they are shown the admin area 
else 
{ 
?>

html goes here

<?php
} 
} 
} 
else 

//if the cookie does not exist, they are taken to the login screen 
{ 
echo "<center><a href='index.php'>You DO Not Have Permission to View this Page! Please Click Here to Log In</a></center>"; 
} 
?>
Scottmandoo 0 Junior Poster in Training

yeah that worked thanks, though i still had to put the img code in, setting the width to 0 so the background image would display but the actual image wouldnt.

<div style="position:absolute; top: 58px; width:100%; height:699; background-image:url(images/bg-image-1.jpg); background-repeat:no-repeat; background-position:center;" align="center"><img src="images/bg-image-1.jpg" width="0" height="699" /></div>
Scottmandoo 0 Junior Poster in Training

ok first off please look at the following images

http://monstermonsterstudios.com/clients/dropdesignstudio/Picture%207.png
http://monstermonsterstudios.com/clients/dropdesignstudio/Picture%208.png

What i want to do is if the window width is smaller than the width of the image i want it to keep going passed the left margin if that makes sense?

<div style="position:absolute; overflow:hidden; top: 58px; width:100%;" align="center"><img src="images/bg-image-1.jpg" width="1264" height="699" /></div>
Scottmandoo 0 Junior Poster in Training

Ok so heres the site: http://allegro1dancestudio.com/

Ive made an event calendar for that site which uses a flat-file database. The calendar part works fine, however, the code is able to make the file but will not write to it and therefore I dont know if i can even get event info from it.

And also once the cal_events.text file is made I do change the permissions so it is writable.

heres the calendar code

<?php
date_default_timezone_set('Australia/Melbourne');

define("EVENT_FILE", "cal_events.text"); 

// Get values from query string 
$day = $_GET["day"]; 
$month = $_GET["month"]; 
$year = $_GET["year"]; 
$sel = $_GET["sel"]; 
$what = $_GET["what"]; 

if($day == "") 
$day = date("j"); 

if($month == "") 
$month = date("m"); 

if($year == "") 
$year = date("Y"); 

$currentTimeStamp = strtotime("$year-$month-$day"); 
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp); 
$counter = 0; 
$numEventsThisMonth = 0; 
$hasEvent = false; 
$todaysEvents = "";

$arrEvents = ReadEvents($month); 

function ReadEvents($Month) 
{ 
// We will get all of the events for this month into an associative 
// array and that array will then be returned 

$theEvents = array(); 
$eventCounter = 0; 

// Make sure that the file exists 
if(!file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE)) 
{ 
$fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "w") 
or die("<span class='error'>ERROR: Couldn't create events file.</span>"); 
@fclose($fp); 
} 

$fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "rb") 
or die("<span class='error'>ERROR: Couldn't open events file to read events.</span>"); 

while($data = fread($fp, 1024)) 
{ 
$events .= $data; 
} 

@fclose($fp); 

// Seperate the data into line-seperated arrays 
$arrEvents = explode("\r\n", $events); 

// …
Scottmandoo 0 Junior Poster in Training

Try adding this in at the start of the code. However, where it says "Australia/Melbourne" change that to your timezone.

Supported ones can be found here: http://au2.php.net/manual/en/timezones.php date_default_timezone_set('Australia/Melbourne'); hope it helps

Scottmandoo 0 Junior Poster in Training

nvm i figured it out heres the code for anyone who wants to have a simple calendar.

<?php 
// Get values from query string 
$day = $_GET["day"]; 
$month = $_GET["month"]; 
$year = $_GET["year"]; 
$sel = $_GET["sel"]; 
$what = $_GET["what"]; 

if($day == "") 
$day = date("j"); 

if($month == "") 
$month = date("m"); 

if($year == "") 
$year = date("Y"); 

$currentTimeStamp = strtotime("$year-$month-$day"); 
$monthName = date("F", $currentTimeStamp); 
$numDays = date("t", $currentTimeStamp); 
$counter = 0; 
$numEventsThisMonth = 0; 
$hasEvent = false; 
$todaysEvents = "";
?>

<table width='320' border='0' cellspacing='2' cellpadding='0'> 
<tr>
<td colspan="7" align="left" valign="bottom"><div class="event"></div></td>
</tr>
<tr>
<tr>
<td colspan="7" align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="image" src="images/month-prev-2.png" width="30" height="33" onmouseover="this.src='images/month-prev-1.png'" onmouseout="this.src='images/month-prev-2.png'" onClick='goLastMonth(<?php echo $month . ", " . $year; ?>)' /><input type="image" src="images/month-next-2.png" width="30" height="33" onmouseover="this.src='images/month-next-1.png'" onmouseout="this.src='images/month-next-2.png'" onClick='goNextMonth(<?php echo $month . ", " . $year; ?>)' /></td>
<td><div class="month"><?php echo $monthName . "."; ?></div></td>
</tr>
</table></td>
</tr>

<?php
$numDays = date("t", $currentTimeStamp); 

for($i = 1; $i < $numDays+1; $i++, $counter++) 
{ 
$timeStamp = strtotime("$year-$month-$i"); 

if($i == 1) 
{ 
// Workout when the first day of the month is 
$firstDay = date("w", $timeStamp); 

for($j = 0; $j < $firstDay; $j++, $counter++) 
echo "<td height='20'>&nbsp;</td>"; 
} 

if($counter % 7 == 0) 
echo "</tr><tr>"; 

if($i == date("d") && $month == date("m") && $year == date("Y")) 
echo "<td height='20' align='center' valign='middle' bgcolor='##0084FF'><font color='#FFFFFF'>$i</font></td>"; 
else
echo "<td height='20' align='center' valign='middle' bgcolor='#999999'><strong>$i</strong></td>";

}

$monthName = date("F", $currentTimeStamp); 
?>

<script type="text/javascript">
function goLastMonth(month, year) 
{ 
// If the month is Januaru, decrement the year 
if(month == 1) 
{ …
Scottmandoo 0 Junior Poster in Training

im trying to set up a calendar using the code from the following site, however i have only got up to the code displayed below, which the site says it should show a calendar however im getting this error. I do however want to set up the whole calendar to use it with events and a flat-file database, so if anyone can maybe check out the site and tell me why it isnt working i'd appreciate it.

Btw its supposed to have the source code to download, but if you read the comments you will learn that its not there.

Parse error: syntax error, unexpected $end in /home2/lifeimpr/public_html/allegro/calendar/cal.php on line 58

The site: http://www.devarticles.com/c/a/PHP/A-Useful-Event-Calendar-Written-In-PHP/2/

<?php
// Get values from query string 
$day = $_GET["day"]; 
$month = $_GET["month"]; 
$year = $_GET["year"]; 
$sel = $_GET["sel"]; 
$what = $_GET["what"]; 

if($day == "") 
$day = date("j"); 

if($month == "") 
$month = date("m"); 

if($year == "") 
$year = date("Y"); 

$currentTimeStamp = strtotime("$year-$month-$day"); 
$monthName = date("F", $currentTimeStamp); 
$numDays = date("t", $currentTimeStamp); 
$counter = 0; 
$numEventsThisMonth = 0; 
$hasEvent = false; 
$todaysEvents = ""; 
?>

<table width='350' border='0' cellspacing='0' cellpadding='0'> 
<tr> 
<td class='head' width='50'>S</td> 
<td class='head' width='50'>M</td> 
<td class='head' width='50'>T</td> 
<td class='head' width='50'>W</td> 
<td class='head' width='50'>T</td> 
<td class='head' width='50'>F</td> 
<td class='head' width='50'>S</td> 
</tr> 

<?php 
$numDays = date("t", $currentTimeStamp); 

for($i = 1; $i < $numDays+1; $i++, $counter++) 
{ 
$timeStamp = strtotime("$year-$month-$i"); 

if($i == 1) 
{ 
// Workout when the first day of the month is 
$firstDay = date("w", $timeStamp); 

for($j = 0; $j …
Scottmandoo 0 Junior Poster in Training

Hey thanks, yeah that was it. :)

Scottmandoo 0 Junior Poster in Training

Im not sure if this is a php problem or javascript, but since the actual photo gallery is run by javascript I'll post it here, sorry if its not though.

Everything works fine but when I click on another image to change the main image the caption wont change with it.

<script type="text/javascript">
// Gallery script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004-08 [url]www.cryer.co.uk[/url].
// Script is free to use provided this copyright header is included.function LoadGallery(pictureName,imageFile,titleCaption,captionText)
function LoadGallery(pictureName,imageFile)
{
	var picture = document.getElementById(pictureName);
	if (picture.filters)
	{
		picture.style.filter="blendTrans(duration=1)";
		picture.filters.blendTrans.Apply();
	}
	picture.src = imageFile;
	if (picture.filters)
	{
		picture.filters.blendTrans.Play();
	}
	document.getElementById(titleCaption).innerHTML=captionText;
}
            </script>
            <?

$con = mysql_connect('','','') or die('Error: ' . mysql_error());
mysql_select_db('') or die('Error: ' . mysql_error());

$colNum = 1;

$sql = "SELECT * FROM `` ORDER BY `id` DESC LIMIT 0, 1";
$query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
$table = '<table align="center" border="0" width="20px" cellpadding="0" cellspacing="0">';
$table .= '<tr>';
$num = 1;
while ($r = mysql_fetch_array($query)) {
	$id=$r['id'];
	$name=$r['name'];
	$image=$r['image'];
	$caption=$r['caption'];
$table .=<<<HTML
<td>
<table border=0 width=20px cellpadding=2 cellspacing=0>
	<tr>
		<td align=center>
			<img src=$image height=400px alt=$name id=showreel>
			<div id="showcaption">$caption</div>
		</td>
	</tr>
</table>
</td>
HTML;
	if ($num == $colNum) {
		$table .= '</tr><tr>';
		$num = 0;
	}
$num++;
}
$table .= '</table>';

echo $table;

mysql_close($con);

?>
            </p>
                    
                    <p class="century-gothic"><?

$con = mysql_connect('','','') or die('Error: ' . mysql_error());
mysql_select_db('') or die('Error: ' . mysql_error());

$colNum = 12;

$sql = "SELECT * FROM `` ORDER BY `id` DESC LIMIT …
Scottmandoo 0 Junior Poster in Training

Thanks antwan that was the problem.

Scottmandoo 0 Junior Poster in Training

in the following piece of code the else part of my if/else statements doent seem to work it just adds nothing, thanks.

btw genre is a dropbox (and yes i have added the values) and genre2 is a text box, same with the filehost and filehost2.

$name      = $_POST['song'];
$artist    = $_POST['artist'];
$genre     = $_POST['genre'];
$genre2    = $_POST['genre2'];
$filehost  = $_POST['filehost'];
$filehost2 = $_POST['filehost2'];
$link      = $_POST['link'];

if($genre="other")
{$genre=$genre2;} 
else{$genre=$genre;}

if($filehost="other")
{$filehost=$filehost;} 
else{$filehost=$filehost;}


	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `songs` VALUES ('','$name','$artist','$genre','$filehost','$link')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());
Scottmandoo 0 Junior Poster in Training

thaks heaps! :)

Scottmandoo 0 Junior Poster in Training

sorry for the double post but heres another code i've tried which seems to be more promising, but it seems to reject everything.

var emailFilter=/^.+@.+\..{2,3}$/;
if (!(emailFilter.test(document.submitform.email))) { 
   alert("Please enter a valid email address!"); return false;
}
Scottmandoo 0 Junior Poster in Training

thanks heaps it works perfectly now.

Scottmandoo 0 Junior Poster in Training

Well heres the code im using, can anyone either fix this code to make it work or suggest a better way of doing this, thanks.

function ValidateForm() {
  if (document.submitform.email.value=="") {
    alert("There is no email entered!"); return false;
  }
  
  if (document.submitform.email.value=="Enter your email...") {
    alert("Please enter an email!"); return false;
  }
  
  if (document.submitform.email.str.indexOf(".") > 2) {
  	alert("Please enter a valid email"); return false;
  }
  
  if (document.submitform.email.str.indexOf("@") > 0) {
  	alert("Please enter a valid email"); return false;
  }
  
  return true;
}
Scottmandoo 0 Junior Poster in Training

Can anyone tell me why this code isnt working?

<?php
	$username = 
	$password = 
	$database = 
	
	$email23 = $_POST['email'];

	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "SELECT * FROM `user_user` WHERE `email` = '$email23'";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());
	$r = mysql_fetch_row($query);
	
	$id = $r['id'];
	
	$sql2 = "DELETE FROM `user_user` WHERE `id` = '$id' ";
	$query = mysql_query($sql2) or die('Error: ' . mysql_error());
	
	$sql2 = "DELETE FROM `listuser` WHERE `userid` = '$id' ";
	$query = mysql_query($sql2) or die('Error: ' . mysql_error());

mysql_close();

?>
Scottmandoo 0 Junior Poster in Training

Ok so I used Adobe Photoshop to generate my Photo Gallery Code, the default index.html page it creates works fine when i upload it to my site but as soon as I add my sites layout around the code it does not seem to work, can anyone please help me.

Page with problem: http://lovedbydesign.com/store/t-shirt-1/index.html
What it should look like in the empty table cell in the above page: http://lovedbydesign.com/store/t-shirt-1/index2.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>T-Shirt 1 Test page</title>

<!-- FlashObject embed by Geoff Stearns geoff@choppingblock.com http://choppingblock.com/ -->

<script type="text/javascript" src="flashobject.js"></script>



<script type="text/javascript">



	window.onload = function() {

		if ((window.document.getElementById) && (window.document.getElementById('gallery').focus)) {

			window.document.getElementById('gallery').focus();

		}

	}

	

</script>



<style type="text/css">

	/* hide from ie5 mac \*/

	html {

		height: 100%;

		overflow: hidden;

	}

	

	#flashcontent {

		height: 100%;

	}

	/* end hide */



	body {
	height: 100%;
	margin: 0;
	padding: 0;
	background-color: #ffffff;
	background-image: url(../../images/background.png);
	}



.style4 {color: #8B6944}
.style7 {	color: #f15ba3;
	font-weight: bold;
	font-size: 16px;
}
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #000000;
}
a:hover {
	color: #8B6944;
}
</style>
<link href="../../style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" rowspan="6" class="border-left">&nbsp;</td>
  </tr>
  <tr>
    <td class="angled-background"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td rowspan="2"><div align="left"><img src="../../images/header.png" alt="Loved - you wear what you eat" width="246" height="120" /></div></td>
        <td width="55"><div align="center"><a href="faq.php"><img src="../../images/faq.png" alt="faq" width="36" height="58" onmouseover="this.src='../../images/faq-ro.png'" onmouseout="this.src='../../images/faq.png'" border="0"/></a></div></td>
        <td …
Scottmandoo 0 Junior Poster in Training

ok lets make this a little simpler than my last topic.

I found this site which everyone who follows it seems to be getting results from, though it says "You are expected to be knowledgeable in the UNIX shell." which i have got no idea what that even is.

I tried to follow the instuctions as best as I could with no luck so could someone please explain that to me in simpler/noob terms.

Also i can not use .htaccess files so is there anyway i can do this without them?

Thanks,
Scottmandoo

btw im asking here because it also states "Support for these instructions is not available from DreamHost tech support."

Scottmandoo 0 Junior Poster in Training

Bump

^ don't know if your allowed to do that, but I really need help with this problem

Scottmandoo 0 Junior Poster in Training

My webhost currently allows for 2mb uploads via php (default settings).

Now I can not access the main php.ini file and .htaccess is not allowed on free accounts.

So what I wanted to know is am I able to set up a custom php.ini to change the upload settings.

I have found a few tutorials on how to do them but I really don't understand what I am doing so a little help would be appreciated.

Thanks,
Scottmandoo

Edit: this is my php info http://slygraffix.com/info.php

Scottmandoo 0 Junior Poster in Training

Haha yeah I already changed that stuff, thanks again

Scottmandoo 0 Junior Poster in Training

Thanks Heaps, it works now.

Scottmandoo 0 Junior Poster in Training

Ok im getting 2 errors with that code

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/10gbfreehost.com/b/l/a/blastburners/htdocs/index.php on line 516

Warning: Cannot modify header information - headers already sent by (output started at /www/10gbfreehost.com/b/l/a/blastburners/htdocs/index.php:5) in /www/10gbfreehost.com/b/l/a/blastburners/htdocs/index.php on line 531

The first one is this $count_a = mysql_num_rows($result_a); The second one is this header('Location: index.php');

Scottmandoo 0 Junior Poster in Training
if (isset($_POST['submitbutton'])) {
	$id      = $_GET['edit'];
	$author  = $_POST['author'];
	$content = $_POST['content'];
	$today   = $_POST['today'];

	$sql = "UPDATE `blog` SET `author` = '" . $author . "', `content` = '" . $content . "', `today` = '" . $today . "' WHERE `id` = '" . $id . "'";
	$query = mysql_query($sql);
	header('Location: index.php');
}

Hey Helraizer, thanks for the codes though i'm having trouble implementing them into my code, above is the update code could you edit that to include your top code.

Thanks,
Scottmandoo

Oh and kkeith29 this isnt for my site this is for a friends site, though your idea would be good but i don't think im up for doing that much coding yet.

Scottmandoo 0 Junior Poster in Training

ok let ne see if I can make this as clear as I can.

At the moment the edit script is openly accessable by anyone I just want to make it secure again your average person unless thy know the password. For the sake of an example we will make the password scottmandoo.

As you can see on my last script ive added an extra field I want to make it so that of a person uses this script and enters the wrong password, anything other than scottmandoo, the update won't work but if they enter scottmandoo in this new field it will update.

Get me?

Anyway if you need anymore info just let me know.

Btw I dont want to get the password from anywhere though if it will make it any secure then I guess I could make another php file called password.php with $password = 'what ever password I choose'

Scottmandoo 0 Junior Poster in Training

a separate php file which I will call password.php also in this file could I set up maybe 10 usernames and passwords to go with them?

Scottmandoo 0 Junior Poster in Training

Thanks heaps it works great now.

I've been looking on the internet how to do php validations and I can't find exactly what i'm looking for.

What I want is if the user inserts the wrong password in the password field it doesnt submit/update. It shouldnt be hard for you to make this should it? anyway if you do could you write where I have to place the password like 'place password here' and also tell me where I have to put it.

Thanks again +1 rep. :)

Scottmandoo 0 Junior Poster in Training

ok the script now takes me to an edit page, but when I click Save instead of updating the content it deletes it, also it refreshes back to the edit page, can you make it load to index.php.

I have also made some edits to the script that I would like included. One of which is the onClick="javascript:SubmitForm();" which i've added to the save button, though this doesnt seem to work (it works for the actual input form) what it does is stop the form being sent if the any fields are wrong or the password is incorrect it tells you this in an alert, though for this form the alert pops up but the form isnt stopped from being sent, is there anyway you can make it work?

<?
	  
	  $thispage = $_SERVER['PHP_SELF'];

$username="";
$password="";
$database="";

$con = mysql_connect('localhost',$username,$password) or die('Error: ' . mysql_error());
mysql_select_db($database) or die('Error: ' . mysql_error());

if (isset($_POST['submit'])) {
	$id      = $_GET['edit'];
	$author  = $_GET['author'];
	$content = $_GET['content'];
	$today   = $_GET['today'];
	$sql = "UPDATE `blog` SET `author` = '" . $author . "', `content` = '" . $content . "', `today` = '" . $today . "' WHERE `id` = '" . $id . "'";
	$query = mysql_query($sql);
	header('Location: ' . $thispage);
}

$colNum = 1;

$sql = "SELECT * FROM `blog` ORDER BY `id` DESC LIMIT 0, 3";
$query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
$table = '<table border="0" width="100%" cellpadding="0" cellspacing="5">';
$table .= '<tr>';
$num = 1;
while ($r = mysql_fetch_array($query)) { …
Scottmandoo 0 Junior Poster in Training

hey kkeith29, helping me out again I see.

ok what I want is an 'edit' link in the bottom right-hand corner of all three displayed rows, which will allow the user to edit the row clicked on.

I need the following fields to be editted:
today
author
content

if theres anything else you need to know let me know

Scottmandoo 0 Junior Poster in Training

Ok below is my display script, though I have no idea how to make an edit script so could someone either make one for me or if thats too much to ask atleast help me make one.

<?

$username="";
$password="";
$database="";

$con = mysql_connect('localhost',$username,$password) or die('Error: ' . mysql_error());
mysql_select_db($database) or die('Error: ' . mysql_error());

$colNum = 1;

$sql = "SELECT * FROM `blog` ORDER BY `id` DESC LIMIT 0, 3";
$query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
$table = '<table border="0" width="100%" cellpadding="0" cellspacing="5">';
$table .= '<tr>';
$num = 1;
while ($r = mysql_fetch_array($query)) {
	$id=$r['id'];
	$author=$r['author'];
	$content=$r['content'];
	$today=$r['today'];
$table .=<<<HTML
<td>
<table border=1 width=100% cellpadding=2 cellspacing=0>
	<tr width=100%>
		<td width=100% bgcolor=000013>
			<center><b><FONT COLOR=BBFFFF><FONT FACE=Verdana,Arial,Times New I2><FONT SIZE=2>$today:</font></font></font></b><br /><B><FONT COLOR=BBFFFF><FONT FACE=Verdana,Arial,Times New I2><FONT SIZE=1>Written by: $author</font></font></font></b></center>
			<p align=left><FONT FACE=Verdana,Arial,Times New I2><FONT SIZE=2><FONT COLOR=BBFFFF>$content</p>
		</td>
	</tr>
</table>
</td>
HTML;
	if ($num == $colNum) {
		$table .= '</tr><tr>';
		$num = 0;
	}
$num++;
}
$table .= '</table>';

echo $table;

mysql_close($con);

?>
Scottmandoo 0 Junior Poster in Training

what is the letterf1{0}?

letterf1{0} get the first letter of letterf1 which is lowercase font_name

Scottmandoo 0 Junior Poster in Training

Ok im trying to upload an image and a .zip file to 2 different loactions at once aswell as put their links on my mysql database, heres my script, at the moment it displays nothing, does nothing and seriously needs fixing.

<?php

$username="my_username";
$password="my_password";
$database="my_database";

$font_name = ucfirst($_POST['font_name']);
$letter    = $name{0};
$image     = $_FILES['image']['name'];
$file      = $_FILES['file']['name'];
$size      = $_POST['size'];
$letterf1  = strtolower($_POST['font_name']);
$letterf2  = letterf1{0};

if(is_numeric($letter))
{$letter2="#";} 
else { $letter2=$letter;}

if (empty($image)) {
	$result = '<font color=FFFFFF>Please choose a image to upload!</font>';
	$error++;
}
else {
		$filename = stripslashes($image);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "png") && ($extension !== "gif")) {
			$result = '<font color=FFFFFF>Unknown file extension, only .png and .gif images are allowed, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['image']['tmp_name'];
			$sizekb = filesize($tmpFile);
			if ($sizekb > 2000000) {
				$result = '<font color=FFFFFF>The image has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$imageName = '../images/fonts/' . $font_name . '.' . $extension;
				$copy = copy($tmpFile, $imageName);
				if (!$copy) {
					$result = '<font color=FFFFFF>Image upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {

if (empty($file)) {
	$result = '<font color=FFFFFF>Please choose a file to upload!</font>';
	$error++;
}
else {
		$filename = stripslashes($file);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "zip")) {
			$result = '<font color=FFFFFF>Unknown file extension, only .zip files are allowed, please try again</font>';
			$error++;
		}
		else {
			$tmpFile2 = $_FILES['file']['tmp_name'];
			$sizekb = filesize($tmpFile2);
			if ($sizekb2 > …
Scottmandoo 0 Junior Poster in Training

Yep that works now, thanks again :)

Scottmandoo 0 Junior Poster in Training

What are you doing btw ? $letter2 will have the first character of $letter. And, it works for me!

Just uploading some files :)

But when I upload a file starting with 3, it inserts $letter3 as 3 not the # symbol

Scottmandoo 0 Junior Poster in Training
<?php

$username="";
$password="";
$database="";

$tut_name     = $_POST['tut_name'];
$tut_image    = $_FILES['tut_image']['name'];
$letter       = ucfirst($_POST['tut_name']);
$letter2      = $letter{0};
 
if(is_int($letter2))
{$letter3='#';} 
else { $letter3=$letter2;}

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($tut_image)) {
	$result = '<font color=FFFFFF>Please choose a rom to upload!</font>';
	$error++;
}
else {
		$filename = stripslashes($tut_image);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "zip") && ($extension !== "rar")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['tut_image']['tmp_name'];
			$sizekb = filesize($tmpFile);
			if ($sizekb > 8000000) {
				$result = '<font color=FFFFFF>The file has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$imageName = '../files/gba-roms/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $imageName);
				if (!$copy) {
					$result = '<font color=FFFFFF>File upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {

function ByteSize($bytes)  
    { 
    $size = $bytes / 1024; 
    if($size < 1024) 
        { 
        $size = number_format($size, 2); 
        $size .= ' KB'; 
        }  
    else  
        { 
        if($size / 1024 < 1024)  
            { 
            $size = number_format($size / 1024, 2); 
            $size .= ' MB'; 
            }  
        else if ($size / 1024 / 1024 < 1024)   
            { 
            $size = number_format($size / 1024 / 1024, 2); 
            $size .= ' GB'; 
            }  
        } 
    return $size; 
    } 

$size2 = ByteSize($sizekb);

	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `gba_roms` VALUES ('','$letter','$imageName','$letter3','$extension','$size2')";
	$query = mysql_query($sql) or …
Scottmandoo 0 Junior Poster in Training

sorry, just tried testing again and it doesnt make the numbers change to the # symbol

Scottmandoo 0 Junior Poster in Training

Thanks that works perfect!!!

Scottmandoo 0 Junior Poster in Training

ok what i want my code to do is

If $letter2 = a number 1, 2, 3 etc. it sets $letter3 to '#'
If $letter2 = a letter it sets $letter3 to $letter2 so it pretty much stays the same

is that what you wanted to know?

And what my code currently does is just set $letter3 to '#' for letters and numbers

Scottmandoo 0 Junior Poster in Training

Couls someone help me fix this code, I think I need to put in a function and a return but i'm not quite sure.
All the code does is return the value # for everything even letters

$letter       = ucfirst($_POST['tut_name']);
$letter2      = $letter{0};
 
    if($letter2 = 1) 
        { 
        $letter3 = '#';  
        } 
        else if ($letter2 = 2)   
            { 
            $letter3 = '#'; 
            } 
			else if ($letter2 = 3)   
            	{ 
            	$letter3 = '#'; 
            	}
				else if ($letter2 = 4)   
            		{ 
            		$letter3 = '#'; 
            		}
					else if ($letter2 = 5)   
            			{ 
            			$letter3 = '#'; 
            			}
						else if ($letter2 = 6)   
            				{ 
            				$letter3 = '#'; 
            				}
							else if ($letter2 = 7)   
            					{ 
            					$letter3 = '#'; 
            					}
								else if ($letter2 = 8)   
            						{ 
            						$letter3 = '#'; 
            						}
									else if ($letter2 = 9)   
            							{ 
            							$letter3 = '#'; 
            							}
										else if ($letter2 = 0)   
            								{ 
            								$letter3 = '#'; 
            								}
					else $letter3 = $letter{0};
Scottmandoo 0 Junior Poster in Training

Thanks a lot, I don't think I could ask anymore from you, though if theres anything I need help with i'll let you know, if thats fine with you, but until then I think this topic has been solved as all I can do now is just wait for my host to update the php.ini.

Thanks again,
Scottmandoo

Scottmandoo 0 Junior Poster in Training

Nah im not going to process it, unless you can edit my script to check for, which i highly doubt, that should be it.

Also i've been doing some research and just wanted to ask you is there a way I can use ftp in my script to upload the file so that I won't have to change those settings or will this process still require for those setting to be changed?

Scottmandoo 0 Junior Poster in Training

Are you saying that the total file size of all files in your hosting must not be higher than 8 MB? Boy that's not much :-) Try http://pipni.cz/

Yeah I know it sucks, but thats the only downfall of my host along with no .htaccess support for free accounts, it provides 10gb of storage, 20gb monthly bandwidth, no ads and heaps more. http://10gbfreehost.com

Also so what your saying is I only need the following editted?
upload_max_filesize 8M
post_max_size 8M
max_input_time 384

Scottmandoo 0 Junior Poster in Training

Sorry I havnt replied for a while, I've been on holidays for the weekend and just gut back.

My web server doesnt allow .htaccess files because...

htaccess eats a lot of server resources and this is why it is not allowed on our free plan.

So I have asked my web server admin if theres any chance of changing those settings in the php.ini with no reply as of yet. Though the web host on very new and is still constantly changing settings to help out its members so theres a high chance the settings will get changed.

What I want to know is, if the host asks what I want all these settings (upload_max_filesize, post_max_filesize, max_execution_time, max_input_time and memory_limit) changed to what should I say? Remember the max file size my host accepts for free accounts is currently 8mb.

Scottmandoo 0 Junior Poster in Training

Thanks it works now, just one more problem though, when I upload files over 2mb it doesnt work. I get the first error "Please choose a rom to upload!"

<?php

$username="my_username";
$password="my_password";
$database="my_database";

$tut_name     = $_POST['tut_name'];
$letter       = ucfirst($_POST['tut_name']);
$tut_image    = $_FILES['tut_image']['name'];

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($tut_image)) {
	$result = '<font color=FFFFFF>Please choose a rom to upload!</font>';
	$error++;
}
else {
		$filename = stripslashes($tut_image);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "zip") && ($extension !== "rar")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['tut_image']['tmp_name'];
			$sizekb = filesize($tmpFile);
			if ($sizekb > 8000000) {
				$result = '<font color=FFFFFF>The file has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$imageName = '../files/gba-roms/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $imageName);
				if (!$copy) {
					$result = '<font color=FFFFFF>File upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {
	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `gba_roms` VALUES ('','$tut_name','$imageName','$letter')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());

mysql_close();
}



?>

Also you may knowtice in this script it doesnt contain most of your advice, this is because when I tried it my page just loaded blank, unless I did it wrong let me know.

Also note I am able to upload …

Scottmandoo 0 Junior Poster in Training

Heres what I got...

Notice: Undefined index: rom_name in /www/10gbfreehost.com/b/l/a/blastburners/htdocs/gba_roms/insert-gba.php on line 490

Notice: Undefined index: rom in /www/10gbfreehost.com/b/l/a/blastburners/htdocs/gba_roms/insert-gba.php on line 491

Notice: Undefined variable: error in /www/10gbfreehost.com/b/l/a/blastburners/htdocs/gba_roms/insert-gba.php on line 503
Please choose a ROM to upload
Warning: mysql_close(): no MySQL-Link resource supplied in /www/10gbfreehost.com/b/l/a/blastburners/htdocs/gba_roms/insert-gba.php on line 540

Wheres the edit button? Anyway heres my code again using the php code thing

<?php

$username="";
$password="";
$database="";

$rom_name     = $_POST['rom_name'];
$rom    = $_FILES['rom']['name'];

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($rom)) {
	$result = '<font color=FFFFFF>Please choose a ROM to upload</font>';
	$error++;
}
else {
		$filename = stripslashes($rom);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "zip") && ($extension !== "ZIP") && ($extension !== "rar") && ($extension !== "ZIP")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['rom']['tmp_name'];
			$sizekb = filesize($tmpFile);
			if ($sizekb > 5000000) {
				$result = '<font color=FFFFFF>The file has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$romName = '/gba_roms/files/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $romName);
				$letter = ucfirst($rom_name);
				if (!$copy) {
					$result = '<font color=FFFFFF>File upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {
	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `gba_roms` …
Scottmandoo 0 Junior Poster in Training

Is there anything wrong with this script?

<?php

$username="";
$password="";
$database="";

$rom_name     = $_POST['rom_name'];
$rom    = $_FILES['rom']['name'];

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($rom)) {
	$result = '<font color=FFFFFF>Please choose a ROM to upload</font>';
	$error++;
}
else {
		$filename = stripslashes($rom);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "zip") && ($extension !== "ZIP") && ($extension !== "rar") && ($extension !== "ZIP")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['rom']['tmp_name'];
			$sizekb = filesize($tmpFile);
			if ($sizekb > 5000000) {
				$result = '<font color=FFFFFF>The file has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$romName = '/gba_roms/files/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $romName);
				$letter = ucfirst($rom_name);
				if (!$copy) {
					$result = '<font color=FFFFFF>File upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {
	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `gba_roms` VALUES ('','$rom_name','$romName','$letter')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());
}

mysql_close();

?>
Scottmandoo 0 Junior Poster in Training

Thanks kkiehth29, but again another problem, heres what I get. Error: Column count doesn't match value count at row 1 Edit: nvm it works now, thanks a lot

Scottmandoo 0 Junior Poster in Training

Alright this is my code, the error im getting is in red

<?php

include("dbinfo.inc.php");

$tut_name     = $_POST['tut_name'];
$tut_link     = $_POST['tut_link'];
$tut_program  = $_POST['tut_program'];
$tut_category = $_POST['tut_category'];
$tut_video    = $_POST['tut_video'];
$tut_download = $_POST['tut_download'];
$tut_image    = $_FILES['tut_image']['name'];

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($tut_image)) {
	$result = '<font color=FFFFFF>Please choose a photo to upload</font>';
	$error++;
}
else {
		$filename = stripslashes($tut_image);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "jpg") && ($extension !== "jpeg") && ($extension !== "png") && ($extension !== "gif")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['tut_image']['tmp_name'];
			$size = getimagesize($tmpFile);
			$sizekb = filesize($tmpFile);
			if ($sizekb > 10000) {
				$result = '<font color=FFFFFF>The image has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$imageName = '../images/tutorials/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $imageName);
				if (!$copy) {
					$result = '<font color=FFFFFF>Image upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {
	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `tutorials` VALUES ('','$tut_name','$tut_link','$tut_program','$tut_category','$tut_video','$tut_download','$imageName')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());
}

mysql_close();

?>

I have also CHMODed my file destination to 777 permision