Shoutbox

php/mysql review database - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: php/mysql review database (/showthread.php?tid=29627)

php/mysql review database by Eljay on 08-07-2004 at 02:30 PM

as u may know im making a site that has reviews, previews, screenshots and other stuff to do with games (including a forum)
problem is i dont know php ot mysql :P
so i need somebody to help me code it or give me places with code examples/tutorials
anyone?


RE: php/mysql review database by Concord Dawn on 08-07-2004 at 03:40 PM

or try W3schools.com.


RE: php/mysql review database by Eljay on 08-08-2004 at 09:00 AM

well i learnt how 2 upload files (quite easy) but now i need to know how 2 limit the file type using php if this is possible


RE: php/mysql review database by WDZ on 08-08-2004 at 09:17 AM

quote:
Originally posted by leejeffery
well i learnt how 2 upload files (quite easy) but now i need to know how 2 limit the file type using php if this is possible
I assume you want to limit files based on their extensions? Here's some simple example code...

code:
<?php

$filename = "uploaded.txt";

$extension = substr(strrchr($filename, "."), 1);

if($extension == "php" || $extension == "php3") {
    die("That file type is banned!");
}

?>

Or if you want to allow only certain types...

code:
if($extension != "jpg" && $extension != "gif") {
    die("Only .jpg and .gif files are allowed!");
}

Of course, the $filename line has to be removed, and then on the line below that, you need to replace $filename with whatever variable your script uses.
RE: php/mysql review database by Eljay on 08-08-2004 at 09:39 AM

thanx WDZ ;)
just what i needed
but im also lookin for a way to not have 2 upload a file to the same database but to have input boxes like game name, reviewer name, review, rating etc. on a page and a button that says submit which adds all the info in the text boxes to a new row in the db
is this possibe?


RE: php/mysql review database by musicalmidget on 08-08-2004 at 10:39 AM

Yes, this is possible, but you would need to write the input form in HTML.

What are your HTML skills like?


RE: php/mysql review database by Eljay on 08-08-2004 at 12:20 PM

quote:
Originally posted by musicalmidget
What are your HTML skills like?
basic
i didnt think i really needed to learn b4 because i use dreamwever
RE: php/mysql review database by bach_m on 08-08-2004 at 03:20 PM

quote:
Originally posted by leejeffery
do i need to learn html or can i do it in dreamweaver?
well, it depends on what you are doing. HTML and CSS skills are very important tools. otherrwise, your code can be filled with wiered empty cells and ones with just spaces in them if you use the dreamweaver "Design" tab to deal with the layout and everything.

I use Dreamweaver at work and at home, but mostly in the coding section, as it provides useful tools like the CSS refernece and the little popup menus etc. But to make the whole site in the design section will make it very confusing code (i know from experience).

That being said, XHTML isn't very hard. its baisically HTML with a few tweaks so ur code doesn't look like a 2 year olds. and CSs is rather simple. C|Net has some great info on CSS here(for a list), and specifically here, here, here,
here. here, and here. i used all of those, and they provided alot of help.

In a nutshell, (X)HTML and CSS=GOOD, dreamweaver design tab=not horrible
RE: php/mysql review database by Eljay on 08-08-2004 at 04:02 PM

here is the code i have but its not actually submitting anything to the database (ive excluded names of db and password for security reasons)
[/code]<?
//initilize PHP

if($_POST['submit']) //If submit is hit
{
   //then connect as user
   //change user and password to your mySQL name and password
   mysql_connect("localhost","******_*****","********");

   //select which database you want to edit
   mysql_select_db("******_reviews");

   //convert all the posts to variables:
   $Title = $_POST['Title'];
   $Platform = $_POST['Platform'];
   $Review = $_POST['Review'];
   $Reviewer = $_POST['Reviewer'];
   $Rating = $_POST['Rating'];
   $Date = $_POST['Date'];
   
   //Insert the values into the correct database with the right fields
   //mysql table = database
   //table columns = Title, Platform, Review, Reviewer, Rating, Date
   //post variables = $Title, $Platform, '$Review, $Reviewer, $Rating, $Date
   $result=MYSQL_QUERY("INSERT INTO database (Title,Platform,Review,Reviewer,Rating,Date)".
      "VALUES ('$Title', '$Platform', '$Review', '$Reviewer', '$Rating', '$date')");

    //confirm
   echo "Review uploaded succesfully!";
}

else
{
// close php so we can put in our code
?><title>GameSmart - Write your own game reviews!!</title>
<style type="text/css">
<!--
.style1 {color: #666666}
-->
</style>

<form action="uploadreview.php" method="post" class="style1">
<TABLE>
<TR>
   <TD align="center" valign="top">Title:</TD>
   <TD><INPUT TYPE='TEXT' NAME='Title' VALUE='' size=60></TD>
</TR>
<TR>
   <TD align="center" valign="top">Platform:</TD>
   <TD>
    <SELECT NAME='Platform'>
    <OPTION VALUE='PS2'>PS2
    <OPTION VALUE='Gamecube'>Gamecube
    <OPTION VALUE='XBOX'>XBOX
    <OPTION VALUE='PC'>PC
    <OPTION VALUE='GBA'>GBA
    </SELECT></TD>
</TR><br>
<TR>
   <TD align="center" valign="top">Review:</TD>
   <TD><textarea name="Review" cols="60" rows="20"></textarea></TD>
</TR>
<TR>
  <TD align="center" valign="top">Rating:</TD>
  <TD><input name='Rating' type='TEXT' size=3 maxlength="2">
    /10</TD>
</TR>
<TR>
  <TD align="center" valign="top">Reviewer:</TD>
  <TD><INPUT NAME='Reviewer' TYPE='TEXT' size=60 maxlength="30"></TD>
</TR>
<TR>
   <TD align="center" valign="top">Date:</TD>
   <TD><INPUT TYPE='text' NAME='Date' VALUE='<? echo date("M.j.y"); ?>' size=60></TD>
</TR>
<TR>
   <TD></TD><br>
   <TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>

<?
} //close the else statement
?>[/code]
can anybody see whats wrong with this code?


RE: php/mysql review database by bach_m on 08-08-2004 at 05:36 PM

quote:
Originally posted by leejeffery

$Date
   $result=MYSQL_QUERY("INSERT INTO database (Title,Platform,Review,Reviewer,Rating,Date)".
      "VALUES ('$Title', '$Platform', '$Review', '$Reviewer', '$Rating', '$date')");
variable names are case-sensitive.

what error do u get?
RE: php/mysql review database by Eljay on 08-08-2004 at 05:43 PM

i changed that but it still dont upload anything
i dont get an error it says review uploaded successfuly like it should and then i go to phpmyadmin to check out the table "database" and theres nothing there :/

EDIT: could it be something to do with the database because i dont know what i was supposed to do with some of the settings so how do i change it so i can put text in?

SORT OF OFF TOPIC: is it possible using html to load a html page into a table?


RE: php/mysql review database by bach_m on 08-08-2004 at 06:04 PM

You need to have a database table set up, with the columns that you want.

look at this for more info, and maybe :google:


RE: php/mysql review database by Eljay on 08-08-2004 at 06:16 PM

no thats not the problem
i have the database set up and have a table with all the needed things like Title, Review etc.
the problem is all the settings like attributes, null and all that sort of stuff
i dont know what they all mean