Jump to content

Updating information

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Guest_Jaan_*

Guest_Jaan_*
  • Guests
I have those functions:

<?php

function editMyads(){

$banners_code = $_GET['code'];

$query = mysql_query("SELECT * FROM banners WHERE banner_code='".mysql_real_escape_string($banners_code)."'");
$row = mysql_fetch_array($query);
$id = $row['user_id'];
$size = $row['size'];
$size_cat = explode("-", $size);
$size_cat = $size_cat['1'];
$size_cut = explode("x", $size);
$size_cut_1 = $size_cut['0'];
$size_cut_2 = $size_cut['1'];
$removeWord = explode("-", $size_cut_2);
$fullSize = $size_cut_1." x ".$removeWord['0'];
$dest_url = $row['gourl'];
$bannerurlFull = explode("/", $row['url']);
$bannerurl = $bannerurlFull['2'];
$bannersname = $row['name'];
?>

<center><font><b>Edit banner: <i><a><?php echo $bannersname; ?></a></i></b></font></center><br>
<form action='index.php?act=myads&option=edit&do=update&code=<?php echo $banners_code; ?>' method='post'>
<table width='390' border='0' align='center'>
	<tr>
	<td width='25%'><font><b>Banner's size:</b></font></td><td width='75%'>
	
	<select name='banner_size'>
	<optgroup label='<?php echo $size_cat; ?>'>
	<option value='<?php echo $size; ?>'><?php echo $fullSize; ?></option>
	</optgroup>
	</select>
	
	</td>
	</tr>
	<tr>
	<td width='25%'><font><b>Destination URL:</b></font></td><td width='75%'><input type='text' size='29' value='<?php echo $dest_url; ?>' name='dest_url'></td>
	</tr>
	<tr>
	<td width='25%'><font><b>Banner location:</b></font></td><td width='75%'><font><i> ads/$id/</i></font><input type='hidden' value='ads/$id/' name='banner_path'><input type='text' value='<?php echo $bannerurl; ?>' size='21' name='banner'><font><a href='javascript:findimg(".$id.");'>Find Image!</a></font></td>
	</tr>
	<tr>
	<td width='25%'><font><b>Banner's name:</b></font></td><td width='75%'><input type='text' value='<?php echo $bannersname; ?>' size='29' name='banners_name'></td>
	</tr>
	<tr>
	<td> </td><td><div align='right'><input type='submit' value='Add'>				   </div></td>
	</tr>
	</table>
	</form>
    
<?php
}

function updateMyAds(){

$dest_url = $_REQUEST['dest_url'];
$bannersname = $_REQUEST['banners_name'];
$banner_code = $_GET['code'];
$banner = $_REQUEST['banner'];
$banner_path = $_REQUEST['banner_path'];
$bannersurl = $banner_path."".$banner;

if(empty($dest_url) || empty($banner) || empty($bannersname)){

echo "<br><center><font class='error'>Please fill form correctly!</font></center><br>";

}else{

$query = "UPDATE banners SET gourl = '{$dest_url}', name = '{$bannersname}', url = '{$bannersurl}' WHERE banner_code = '{$banners_code}'";
$result = mysql_query($query);
if(!$result){
die("<font class='error'>Something is wrong: </font><font>".mysql_error()."</font>");
}else{
echo "<br><center><font>Banner updated! <a href='index.php?act=myads'>Go back to My ads!</a></font></center><br>";
}

}

}

and in index.php it will look like this:

...

if(isset($_GET['do']) && $_GET['do'] == "update"){
$action->updateMyAds();
}else{
$action->editMyads();
}

}else{

...

Problemo is that when i try to update my things in database.. then it wont..
i have tried everything.. asked from i don't know.. 2-3 whats wrong.. but they don't know.. maybe someone knows..

#2
bvaessen

bvaessen

    Newbie

  • Members
  • PipPip
  • 27 posts
What exactly does happen?
What are these curly brackets {} needed for in the SQL statement?
What is the type of banners_code? in case it is an integer, there should not be '' in the SQL statement, plus:
If I am correct, I see once bannerS_code and once banner_code. That could also lead to the bug doesnt it?
-------------------------------------------------------------------------
Ben Vaessen :: Home
Launch-IT :: Home

#3
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
The code you posted is not a class. Why are you trying to use it as one?
$action->updateMyAds();
Is $action an object?

#4
Guest_Jaan_*

Guest_Jaan_*
  • Guests
lol awesome.. thanks :D i didnt notice those little mistakes