Jump to content

Can you look at this and tell me whats wrong please.


richarro1234

Recommended Posts

Hey all,

i have this peice of code,

it was working fine untill i added the str_replace() command and now it doesnt work.

 

here is the code:

 

include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);

$txt = str_replace(";", "<br>", $_POST['newinfo']);

$query = mysql_query("UPDATE recipes SET $get = $txt WHERE id = $uid");
	header ("Location: editrecipe.php?note=1");
die();
}

 

Thanks

Rich

Link to comment
Share on other sites

Hey sorry, i was thinking of the wrong command whilst adding it, i have changed it now.

Well it comes up with a msg saying that it has been added to the database (which i have added as a bit of code a bit further up the page) but it doesnt update the database.

As it work s it just doesnt update the database then theres no errors.

 

Thanks

Rich

Link to comment
Share on other sites

nope no errors, it runs the script properly as it shows up the msg that it was added successfully, but it just doesnt get the info from the textarea to the database.

here is the full code incase the error lies elsewhere:

 

<?
include("data.php");
//include("funktioner.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
if ($_GET['action'] == 'update') {

if ($_COOKIE["lilyusername"] == 'lily' || $_COOKIE["lilyusername"] == 'richarro123') {
$editlist = $_GET['get'] == 'name' || $_GET['get'] == 'ingrediants' || $_GET['get'] == 'method';
} else {
$editlist = $_GET['get'] == 'thugs' || $_GET['get'] == 'turns';
}

if ($editlist) {

$get = ($_GET['get']);
$uid = ($_GET['id']);

if ($_POST['newinfo'] == '') {
header ("Location: editrecipe.php?error=1");
die();
}

include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
$query = mysql_query("SELECT * from recipes WHERE id = '$uid'");
while ($ther = mysql_fetch_array($query)) {
$there = "yes";
$memuname = $ther['username'];
$oldvalue = $ther[$get];
}
if ($there == FALSE) {
header ("Location: editrecipe.php?error=2");
die();
}

include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);

$txt = str_replace(";", "<br>", $_POST['newinfo']);

$query = mysql_query("UPDATE recipes SET $get = $txt WHERE id = $uid");
	header ("Location: editrecipe.php?note=1");
die(mysql_error());
}
}
?>
<?include("header.php");?>
<?
if ($_COOKIE["lilystatus"] == "online") {
include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
$query = mysql_query("SELECT * from users WHERE username = '".$_COOKIE["lilyusername"]."'");
while ($r = mysql_fetch_array($query)) {
?>
<?
// Error messages

if ($_GET['error'] == '1') {
	$note = "<br><center>
			 <table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='75%' id='AutoNumber1' bordercolor='red' bgcolor='#000000'>
				<tr>
				  <td width='100%' align='center'><font color='red' size='2'><b>You have to enter in something!</b></font></td>
				</tr>
			 </table>
			 </center><br>";
	}

if ($_GET['error'] == '3') {
	$note = "<br><center>
			 <table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='75%' id='AutoNumber1' bordercolor='red' bgcolor='#000000'>
				<tr>
				  <td width='100%' align='center'><font color='red' size='2'><b>Sorry couldn't edit that Article!</b></font></td>
				</tr>
			 </table>
			 </center><br>";
	}
// Note messages

if ($_GET['note'] == '1') {
	$note = "<br><center>
			 <table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='75%' id='AutoNumber1' bordercolor='red' bgcolor='#000000'>
				<tr>
				  <td width='100%' align='center'><font color='red' size='2'><b>The article info was updated successfully!</b></font></td>
				</tr>
			 </table>
			 </center><br>";
	}
?>
<center>
<?=$note?></center>
<br>
<? 
if ($r['rank'] == 'admin' || $r['rank'] == 'headadmin') {
?>
<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="75%" id="AutoNumber7" bgcolor="#000000">
  <tr>
    <td width="100%" align="center"><font size="2"><b>Here is where you can Alter Any Article you want.</b></font></td>
  </tr>
</table>
  </center>
</div>
<br>
<? if ($_GET['action'] == '') { ?>
<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="75%" id="AutoNumber4" bgcolor="#131313">
  <tr>
    <td width="100%" colspan="3" height="14" bgcolor="#000000">
    <p align="center"><b>Get Recipe</b></td>
  </tr>
  <tr>
    <td width="100%" colspan="3" height="14"></td>
  </tr>
  <tr>
    <td width="100%" colspan="3" height="13" align="center">Select the recipe by there ID or name.</td>
  </tr>
  <tr>
    <td width="100%" colspan="3" height="14"></td>
  </tr>
    <form action="editrecipe.php?action=getinfo" method="post">
  <tr>
    <td width="33%" height="20">
    <p align="right">
    <select size="1" name="getby">
      <option selected>ID</option>
      <option>name</option>
      </select>
    </td>
    <td width="33%" height="20" align="center"><input type="text" name="info" size="20"></td>
    <td width="34%" height="20"><input type="submit" value="Submit" name="B1"></td>
  </tr>
</form>
</table>
  </center>
</div>
<?} elseif ($_GET['action'] == 'getinfo') {

include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
$query = mysql_query("SELECT * from recipes WHERE ".$_POST['getby']." = '".$_POST['info']."'");
while ($al = mysql_fetch_array($query)) {

$lastlogindate = date("dS of F, Y \@ h:i a",$al['lastlogin']);
$registereddate = date("dS of F, Y \@ h:i a",$al['reggad']);
?>
<br>
<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="75%" id="AutoNumber5" bgcolor="#131313">
  <tr>
    <td width="100%" colspan="3" bgcolor="#000000">
    <p align="center"><b>Information for <?=$al['name'];?></b></td>
  </tr>
  <tr>
    <td width="100%" colspan="3"> </td>
  </tr>
  <tr>
    <td width="33%">
    <p align="center"><b>ID:</b></td>
    <td width="33%" align="center"><?=$al['id'];?></td>
    <td width="34%"> </td>
  </tr>
  <tr>
    <td width="100%" colspan="3"> </td>
  </tr>
  <tr>
    <td width="33%">
    <p align="center"><b>name:</b></td>
    <td width="33%" align="center"><?=$al['name'];?></td>
    <td width="34%"><a href="editrecipe.php?action=edit&get=name&what=name&id=<?=$al['id'];?>">EDIT</a></td>
  </tr>
  <tr>
    <td width="100%" colspan="3">
     </td>
  </tr>
  <tr>
    <td width="33%">
    <p align="center"><b>Date Posted:</b></td>
    <td width="33%" align="center"><?=$al['ingrediants'];?></td>
    <td width="34%"><a href="editrecipe.php?action=edit&get=ingrediants&what=ingrediants&id=<?=$al['id'];?>">EDIT</a></td>
  </tr>
  <tr>
    <td width="100%" colspan="3">
     </td>
  </tr>
  <tr>
    <td width="33%">
    <p align="center"><b>Article:</b></td>
    <td width="33%" align="center"><?=$al['method'];?></td>
    <td width="34%"><a href="editrecipe.php?action=edit&get=method&what=method&id=<?=$al['id'];?>">EDIT</a></td>
  </tr>
  <tr>
    <td width="100%" colspan="3"> </td>
  </tr>
  <tr>
    <td width="100%" colspan="3"> </td>
  </tr>
</table>
  </center>
</div>
<? $there = "yes"; ?>
<?}?>
<? if ($there == FALSE) {?>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
  <tr>
    <td width="100%">
    <p align="center"><b>Sorry that user doesn't exist!</b></td>
  </tr>
</table>
<?}?>
<?} elseif ($_GET['action'] == 'edit') {

if ($_COOKIE["lilyusername"] == 'lily' || $_COOKIE["lilyusername"] == 'richarro123') {
$editlist = $_GET['get'] == 'name' || $_GET['get'] == 'ingrediants' || $_GET['get'] == 'method';
} else {
$editlist = $_GET['get'] == 'thugs' || $_GET['get'] == 'turns';
}

if ($editlist){

$uid = ($_GET['id']);
$what = ($_GET['what']);
$get = ($_GET['get']);

include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
$query = mysql_query("SELECT * from recipes WHERE id = $uid");
while ($edit = mysql_fetch_array($query)) {
?>
<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="75%" id="AutoNumber6" bgcolor="#131313">
  <tr>
    <td width="100%" colspan="3" align="center" bgcolor="#000000"><b>Edit <?=$edit['name']?>'s <?=$what?></b></td>
  </tr>
  <tr>
    <td width="100%" colspan="3" align="center"> </td>
  </tr>
<form action="editrecipe.php?action=update&id=<?=$uid?>&get=<?=$get?>" method="post">
  <tr>
    <td width="33%">
    <p align="center"><?=$edit['name']?>'s Current <?=$what?>:
    <br>
<?
$dsign = "";
$editget = $edit[$get];
?>
    <?=$dsign?><?=$editget?>
    </td>
    <td width="34%">
<p align="center">
<?php
if ($get == 'method') {?>
<textarea rows="9" name="newinfo" cols="22" class="inquiryform" value="<?=$edit[$get]?>"></textarea>
<?} else if ($get == 'ingrediants') {?>
<textarea rows="9" name="newinfo" cols="22" class="inquiryform" value="<?=$edit[$get]?>"></textarea>
<?} else {?>
<input name="newinfo" maxlength="30" size="20" value="<?=$edit[$get]?>">
<?}?>
</td>
    <td width="33%">
<input type="submit" value="Update">
</td>
  </tr>
</form>
</table>
  </center>
</div>
<?}?>
<?}?>
<?}?>
<?} else {?>
</p>
<center><b>Only Admins May View This Page!</b></center>
<?}?>
<br>
<?
}
} else {
require( 'notloggedin.php' );
}?>
<?include("footer.php");?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.