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 😃

    What exactly is the problem? Could you give us a clue?

    Tip: echo $query
    to see exactly what queries you are submitting.
    and have a look at mysql_error() after the queries.

    You seem fond of text fields which can hold a short novel. Apart from description and the date fields, I'd make the others varchar(N). And the date fields of type date. Just my 0.02p worth.

      o crap sorry i forgot to include the error well here it is sorry about that someone elce on here made that script for me well fixed it when i had an error making a php members section for a website im using the same form just edited abit...

      ive just noticed i dont get an error displayed it says

      New Recruit Added. Your query INSERT INTO php_reviews (gname, desc, img, rlink, t2d, rdate, sdate, pfm, author, amail) VALUES('','kckfylk','ytluf', 'ktdk', 't', 'dk', 'tdk', now()), 'k', 'td', 'ktd', ) is correctThere are 1 rows in the database

      but i already have one in the database so that is the "1rows" part but it isnt adding it when it says New Recruit Added.

      ignore the new recruit added i havnt changed it yet 🙂

      i use text because i dont see the point in varchar and i am new to mysql im only just starting to know how to do php properly c i dont mind not having a form its just i dont trust people getting into phpmyadmin and totaly destroying my database and it is a games website with 16 people working doing reviews and stuff.

        Is that one ) too many where it says "now())" in the query?

        Also there is trailing , at end of values.

          hey i tried that thanks for trying but it didnt work i still need this code asap if anyone can help me please i would be VERY VERY greatfull !

            INSERT INTO php_reviews (gname, desc, img, rlink, t2d, rdate, sdate, pfm, author, amail)
            VALUES('','kckfylk','ytluf', 'ktdk', 't', 'dk', 'tdk', now()), 'k', 'td', 'ktd', )

            I count 10 fields and 11 values to put in them

              tell me please how that helps

              if possible could u add the fix to the main sorce code and post it again as im crap at locating and replacing with php thanks 😉

                $query = "INSERT INTO php_reviews (id, 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']')"; 
                

                Add the id field to the first part of your INSERT statement. Also, the code itself could use some cleaning up. What I provided should be helpful to you...

                P.S. Not to be rude or anything, but I have seen several posts of yours now, and they inevitably end up with you sniping at people trying to help. Just remember, people are here helping each other, and if you don't like their response, it helps if you don't come across as ungrateful. Constructively ask for clarifications, and you will be better received on the boards.
                (This is the comment I am referring to: tell me how that helps )

                  On a side note, did my last post help with your INSERT problem any?

                    nope if possible can u post me the whole page code so i can just use it if you can fix it please !

                      <?php 
                      include "config.php"; 
                      extract($_POST);
                      $today = date("m-d-Y");
                      
                      $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 (id, gname, desc, img, rlink, t2d, rdate, sdate, pfm, author, amail) VALUES ('', '$gname', '$desc', '$img', '$rlink', '$t2d', '$rdate', '$today', '$pfm', '$author', '$amail')"; 
                      $result = mysql_query($query); 
                      
                      ?> 
                      

                      Start with this. If you can get this to work, then you can start messing around with your error checking.

                        <?php  
                        include "config.php";
                        extract($_POST); $today = date("m-d-Y"); $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 (id, gname, desc, img, rlink, t2d, rdate, sdate, pfm, author, amail) VALUES ('', '$gname', '$desc', '$img', '$rlink', '$t2d', '$rdate', '$today', '$pfm', '$author', '$amail')";
                        $result = mysql_query($query); ?>

                        Oops, I left out a single quote... Here is the revised query code.

                          Write a Reply...