Badfish;11041245 wrote:First post newbie here.
I ran a website forum for over 10 years and used xmb forums software and virtually discarded the forums over time and used the site as a template for a login script and connection to my own personal sports database.
Over the years with upgrading of php its virtually useless now as I archive a lot of news articles from other websites and are now having trouble pasting any text that includes apostrophe's and special characters. When I do try it submits the form ok but wont save the record to the database.
I moved domains recently and switched back to an older version of php and that fixed the problem for a while until they upgraded their servers and upgraded php and now its happening again I read something a while ago that there was a problem with php 5.4 and special html character conflicts so its probably my code thats the problem.
Is there any script available as a login and connection template I can use and then upgrade my pages to run with it ?.
There is over 100 pages that I use on the site that will have to be recoded as well, but its the only option I have left by the look of it.
Here is the code from one of the many pages I have. Can you explain to me where and how to update the mysql to mysqli ?.
<?php
// get required global info
define('X_SCRIPT', 'add_ground.php');
require 'header.php';
// load navigation text
$lang['pagetitle'] = 'Ground Editor';
nav($lang['pagetitle']);
loadtemplates(
'css',
'header'
);
// load css
eval('$css = "'.template('css').'";');
// load header
eval('$header = "'.template('header').'";');
echo $header;
if (!X_SADMIN) {
eval('echo stripslashes("'.template('error_nologinsession').'");');
end_time();
eval('$footer = "'.template('footer').'";');
echo $footer;
exit();
}
$venue_id = (isset($venue_id) && is_numeric($venue_id)) ? (int) $venue_id : 0;
// Log
$subid = ($self['uid']);
$result = mysql_query("Select NOW() as subdte");
$row = mysql_fetch_array($result);
$subdte = $row["subdte"];
// Log
echo"<table width=\"$tablewidth\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr><td>";
echo"<table width=\"100%\" cellspacing=\"$borderwidth\" cellpadding=\"$tablespace\" bgcolor=\"$bordercolor\">";
echo"<tr><td class=\"category\"><font color=\"$cattext\"><strong>$lang[pagetitle]</strong></font></td></tr>";
echo"<tr>";
echo"<td class=\"smalltxt\" bgcolor=\"$altbg2\">";
if(isset($POST['submit']))
{
$sql = "INSERT INTO grounds (league_id, venue, venue_abbrev, state, cap, lgth, wdth, info) VALUES ('$league_id','$venue','$venue_abbrev','$state','$cap','$lgth','$wdth','$info')";
$result = mysql_query($sql);
echo"$venue Added.";
// Log
$findid = mysql_query("SELECT venue_id FROM grounds ORDER BY venue_id DESC");
$myrow = mysql_fetch_array($findid);
$logid = $myrow["venue_id"];
$sql = "INSERT INTO dbaselog (subid, subdte, subtype, recid, rectype) VALUES ('$subid', '$subdte', '1', '$logid', '17')";
$result = mysql_query($sql);
// Log
redirect("edit_grounds.php?action=list", 2, X_REDIRECT_JS);
$findid = mysql_query("SELECT venue_id FROM grounds ORDER BY venue_id DESC");
$myrow = mysql_fetch_array($findid);
$id = $myrow["venue_id"];
$qsql = "UPDATE grounds SET q='q$venue_id' WHERE venue_id=$venue_id";
$qresult = mysql_query($qsql);
}
else if(isset($POST['update']))
{
$sql = "UPDATE grounds SET league_id='$league_id',venue='$venue',venue_abbrev='$venue_abbrev',state='$state',cap='$cap',lgth='$lgth',wdth='$wdth',info='$info',id='$id' WHERE venue_id=$venue_id";
$result = mysql_query($sql);
echo"$venue has been succesfully updated.";
// Log
$sql = "INSERT INTO dbaselog (subid, subdte, subtype, recid, rectype) VALUES ('$subid', '$subdte', '2', '$venue_id', '17')";
$result = mysql_query($sql);
// Log
redirect("edit_grounds.php?action=list", 2, X_REDIRECT_JS);
}
else if($venue_id)
{
$result = mysql_query("SELECT * FROM grounds WHERE venue_id=$venue_id");
$myrow = mysql_fetch_array($result);
$result = mysql_query("Select league.league, league.league_id From league Inner Join grounds ON grounds.league_id = league.league_id WHERE venue_id=$venue_id");
$row = mysql_fetch_array($result);
$league = $row["league"];
// Log
$result = mysql_query("Select ".X_PREFIX."members.username as sub, DATE_FORMAT(dbaselog.subdte, 'On %W, %b %D, %Y @%h:%i %p') AS subdte From dbaselog Inner Join ".X_PREFIX."members ON dbaselog.subid = ".X_PREFIX."members.uid Where dbaselog.recid = '$venue_id' AND dbaselog.rectype = '17' Order By dbaselog.subdte Desc Limit 1");
$row = mysql_fetch_array($result);
$sub = $row["sub"];
$subdte = $row["subdte"];
// Log
?>
<form method="post" action="<?php echo $SERVER['PHP_SELF']?>">
<input class="smalltxt" type="hidden" name="venue_id" value="<?php echo $myrow["venue_id"]?>" />
<input class="smalltxt" type="hidden" name="id" value="<?php echo $myrow["id"]?>" />
<br />
<strong>Venue:</strong>
<input class="smalltxt" type="text" name="venue" value="<?php echo $myrow["venue"]?>" size="25" />
<strong>League:</strong>
<?php $result = mysql_query("Select league.league_id AS menuleague_id, league.league AS menuleague FROM league WHERE league.league_id > '1' Order By menuleague Asc"); ?>
<select class="smalltxt" name="league_id" id="league_id">
<option value="<?php echo $myrow["league_id"]?>"><?php echo $league;?></option>
<?php while($row = mysql_fetch_array($result)) { ?>
<option value="<?php echo $row["menuleague_id"]?>"><?php echo $row['menuleague'];?></option>
<?php } ?>
</select><br />
<br />
<strong>Venue Abbreviation:</strong>
<input class="smalltxt" type="text" name="venue_abbrev" value="<?php echo $myrow["venue_abbrev"]?>" size="15" />
<strong>State:</strong>
<input class="smalltxt" type="text" name="state" value="<?php echo $myrow["state"]?>" size="8" /><br />
<br />
<strong>Ground Capacity:</strong>
<input class="smalltxt" type="text" name="cap" value="<?php echo $myrow["cap"]?>" size="12" />
<strong>Ground Length:</strong>
<input class="smalltxt" type="text" name="lgth" value="<?php echo $myrow["lgth"]?>" size="5" />
<strong>Ground Width:</strong>
<input class="smalltxt" type="text" name="wdth" value="<?php echo $myrow["wdth"]?>" size="5" /><br />
<br />
<strong>Venue Info:</strong><br />
<textarea class="smalltxt" name="info" rows="10" cols="100"><?php echo $myrow["info"]?></textarea><br />
<br />
<br />
<strong>Last Updated by:</strong> <?php echo $sub?> <?php echo $subdte?>
<br />
<br />
<br />
<input class="smalltxt" type="submit" name="update" value="Update" />
<br />
<br />
<center><a href="edit_grounds.php?action=list">Back to list of Grounds</a></center><br />
<br />
</form>
<?php
}
else
{
?>
<form method="post" action="<?php echo $SERVER['PHP_SELF']?>">
<br />
<strong>Venue:</strong> <input class="smalltxt" type="text" name="venue" size="25" />
<strong>League:</strong>
<?php $result = mysql_query("Select league.league_id AS menuleague_id, league.league AS menuleague FROM league WHERE league.league_id > '1' Order By menuleague Asc"); ?>
<select class="smalltxt" name="league_id" id="league_id">
<?php while($row = mysql_fetch_array($result)) { ?>
<option value="<?php echo $row["menuleague_id"]?>"><?php echo $row['menuleague'];?></option>
<?php } ?>
</select><br />
<br />
<strong>Venue Abbreviation:</strong> <input class="smalltxt" type="text" name="venue_abbrev" size="15" />
<strong>State:</strong> <input class="smalltxt" type="text" name="state" size="8" /><br />
<br />
<strong>Ground Capacity:</strong> <input class="smalltxt" type="text" name="cap" size="8" />
<strong>Ground Length:</strong> <input class="smalltxt" type="text" name="lgth" size="8" />
<strong>Ground Width:</strong> <input class="smalltxt" type="text" name="wdth" size="8" /><br />
<br />
<strong>Venue Info:</strong><br />
<textarea class="smalltxt" name="info" rows="10" cols="100"></textarea><br />
<br />
<br />
<input class="smalltxt" type="submit" name="submit" value="Enter" />
<br />
<br />
<center><a href="edit_grounds.php?action=list">Back to list of Grounds</a></center><br />
<br />
</form>
<?php
}
echo"</td></tr></table></td></tr></table>";
//Page End
// load footer stuff
end_time();
// load footer
eval('$footer = "'.template('footer').'";');
// transmit response entity
echo $footer;
?>