hi all im Gavin Hanson ive used this before and got some prety cool results so im back to give it another go...
anyway i have been making a script for my games website so i can add reviews without having to teach n00b reviewers how to use phpmyadmin and besides i dont trust them.
anyway this what ive got and what i get.
this page i called "add_review.php" it is only a html form.
<form name="links" method="post" action="insert_review.php">
<p>Game Name :
<input type="text" name="gname">
<br>
<br>
Description / Review :
<textarea rows=20 cols=70 wrap="off" name="desc"></textarea>
<br>
<br>
Image URL :
<input type="text" name="img">
<br>
<br>
Related Link :
<input type="text" name="rlink">
<br>
<br>
Text To Display :
<input type="text" name="t2d"> (For Related Link)
<br>
<br>
Game Releace Date :
<input type="text" name="rdate">
<br>
<br>
Platform :
<input type="text" name="pfm"> (Console/OS)
<br>
<br>
Author :
<input type="text" name="author">
<br>
<br>
Authors E-Mail Address :
<input type="text" name="amail">
<input type="submit" name="Submit" value="Submit">
</p></form>
And this is my "insert_review.php" page
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$query = "INSERT INTO php_reviews (gname, desc, img, rlink, t2d, rdate, sdate, pfm, author, amail)
VALUES('','".$_POST['gname']."','".$_POST['desc']."', '".$_POST['img']."', '".$_POST['rlink']."', '".$_POST['t2d']."', '".$_POST['rdate']."', now()), '".$_POST['pfm']."', '".$_POST['author']."', '".$_POST['amail']."', )";
$result = mysql_query($query);
if (!mysql_affected_rows()){
echo ("Recruit NOT Added.\nQuery $query is wrong");
$query=mysql_query("SELECT * FROM php_reviews");
$count=mysql_num_rows($query);
echo "There are $count rows in the database";
}
else {
echo ("New Recruit Added.\nYour query $query is correct");
$query=mysql_query("SELECT * FROM php_reviews");
$count=mysql_num_rows($query);
echo "There are $count rows in the database";
}
?>
Here is "config.php"
<?php
$db_host = "localhost";
$db_user = "e_novative";
$db_pass = "e_novative";
$db_name = "gameunit";
?>
Here is my "show_reviews.php" page which is working i just thought i would send in all the code.
<?php
include('config.php');
$db = mysql_connect ($db_host,$db_user,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot Connect To Database");
$query = "SELECT * FROM php_reviews";
$result = mysql_query ($query) or die ("There Was An Error During Your MySQL Query.");
while($r=mysql_fetch_array($result)) {
$gname=$r["gname"]; $desc=$r["desc"]; $img=$r["img"]; $rlink=$r["rlink"]; $t2d=$r["t2d"]; $rdate=$r["rdate"]; $sdate=$r["sdate"]; $pfm=$r["pfm"]; $author=$r["author"]; $amail=$r["amail"];
echo "Game Title :$gname<br>
Description : $desc<br>
<img src='$img'><br>
Related Link : <a href='$rlink'>$t2d</a><br>
Releace Date : $rdate<br>
Submission Date :$sdate<br>
Platform : $pfm<br>
Author : <a href='mailto:$amail'>$author</a><br><br>";
}
?>
And finaly this is my "MySQL" Database query
CREATE TABLE php_reviews (
id int(11) NOT NULL auto_increment,
gname text,
desc text,
img text,
rlink text,
t2d text,
rdate text,
sdate text,
pfm text,
author text,
amail text,
UNIQUE KEY id (id)
) TYPE=MyISAM;
Thanks in advance for any help you can offer good bye and i will check back tommorow at this moment in time im off to bed cya