Jump to content


Photo

Help with a Review script i made!


  • Please log in to reply
1 reply to this topic

#1 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 20 February 2006 - 08:54 PM

Ok so i made a a script with 2 files, db.php, and index.php...... here is my script:

db.php:
<?php
// Database variables
$host = 'db304.perfora.net';
$user = 'dbo154983898';
$pass = 'Q439a.gw';
$dbname = 'db1549838989';

// Connect to Mysql Database
$mysql = mysql_connect($host,$user,$pass);
$db = mysql_select_db($dbname,$mysql);

//grab rveiews vars
function reviews($reviews) {
    
    $get_reviews = mysql_fetch_array(mysql_query("select * from reviews"));
    $reviews = $get_reviews[$reviews];
    return $reviews;
}
?>


index.php:
<?php 
include("db.php");

access();

echo ('<h4>Submit a Review</h4>');


if($_POST['options']){
    

    $title  = $_POST['title'];
    $posted = $_POST['posted'];
    $story = $_POST['story'];
    $picturepath = $_POST['picturepath'];
    $quality = $_POST['quality'];
    $effect = $_POST['effect'];
    $overall = $_POST['overall'];

    
    $options = "UPDATE reviews SET title='$title',posted='$posted',story='$story',picturepath='$picturepath',quality='$quality',effect='$effect',overall='$overall'";
    $update_options = mysql_query($options);
    
        echo("Reviews Submited.<br /><br />");
    
}

    
    
$config = mysql_fetch_array(mysql_query("select * from reviews"));
    $title  = $config['title'];
    $posted = $config['posted'];
    $story = $config['story'];
    $picturepath = $config['picturepath'];
    $quality = $config['quality'];
    $effect = $config['effect'];
    $overall = $config['overall'];;

            
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">

<table cellspacing="1" cellpadding="4" border="0" bgcolor="#f2f2f2">

<tr>
  <td width="95">Title: </td><td width="352" style="border-right: 10px solid <? echo $bg1; ?>;"><input type="text" name="bg1" value="<? echo $title; ?>" size="20" /></td></tr>
<tr>
  <td>Posted By : </td><td style="border-right: 10px solid <? echo $bg2; ?>;"><input type="text" name="bg2" value="<? echo $posted; ?>" size="20" /></td></tr>
<tr>
  <td valign="top">Story: </td><td style="border-right: 10px solid <? echo $text; ?>;"><textarea name="text" cols="50" rows="8"><? echo $story; ?></textarea></td></tr>
<tr>
  <td>Picture Url: </td><td><input type="text" name="size" value="<? echo $picturepath; ?>" size="20" /></td></tr>
<tr>
  <td>&nbsp;</td>
  <td><b>Ratings:</b></td>
</tr>
<tr>
  <td>Picture Quality: </td>
  <td><label>
    <select name="select">
      <option value="<? echo $quality; ?>">1</option>
      <option value="<? echo $quality; ?>">2</option>
      <option value="<? echo $quality; ?>">3</option>
      <option value="<? echo $quality; ?>">4</option>
      <option value="<? echo $quality; ?>">5</option>
    </select>
  </label></td>
</tr>
<tr>
  <td>Effects:</td>
  <td><select name="select2">
    <option value="<? echo $effect; ?>">1</option>
    <option value="<? echo $effect; ?>">2</option>
    <option value="<? echo $effect; ?>">3</option>
    <option value="<? echo $effect; ?>">4</option>
    <option value="<? echo $effect; ?>">5</option>
    </select></td>
</tr>
<tr>
  <td>Overall:</td>
  <td><select name="select3">
    <option value="<? echo $overall; ?>">1</option>
    <option value="<? echo $overall; ?>">2</option>
    <option value="<? echo $overall; ?>">3</option>
    <option value="<? echo $overall; ?>">4</option>
    <option value="<? echo $overall; ?>">5</option>
    </select></td>
</tr>
</table>
<br /><br />







<input type="submit" name="options" value="Submit" />
</form>


now everytime i clciiksubmit, it isnt updating the mysql database, how do i go by fixing that? is there a problem wuith my code?

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 20 February 2006 - 09:17 PM

First, don't post entire scripts. Second, your UPDATE statement has no where clause, which means you're updating all the records in the table. Third, I don't see any mysql_error() calls, so how can you determine what the problem is?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users