Jump to content

zeppis

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zeppis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. looks like this [b]$sql = "select bid from plepictures where id={$_POST[image_id]}";[/b]
  2. Ok, I changed all variables to globals within the function and came up with new error [b]Query select bid from plepictures where id=(2\") failed with error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\")' at line 1[/b] that means i have to strip slashes or something?
  3. Ok I changed this is how it looks like [b]function increaseBid() {    $sql = "select bid from plepictures where id='$image_id'"; $result = mysql_query($sql);         if ($result === false) die("Query $sql failed with error " . mysql_error()); $row = mysql_fetch_array($result,MYSQL_ASSOC); $bid = $row[0] + $new_bid; mysql_query("UPDATE plepictures  SET bid='$bid', name='$name', email='$email' WHERE id='$image_id'"); }[/b] Im not getting any errors now but my [b]printf ( mysql_affected_rows()); [/b] IS SHOWING 0, so the database isn't getting nothing http://www.okdesigns.org/  this is the site, now description, pics etc are coming from database so is connected. thanks all
  4. alright these errors are happening within the function I had double quotes in function [b]increaseBid() {    $sql = 'select bid from plepictures where id=$image_id';  [/b] SO I CHANGED THEM TO SINGLE QUOTES AND GOT A NEW ERROR MESSAGE  [b]Query select bid from plepictures where id=$image_id failed with error Unknown column '$image_id' in 'where clause'[/b] is that a prob? I removed the comma also.
  5. Thanks for your help, I took out the @'s, now I inserted the [i] $result = mysql_query($sql);         if ($result === false) die("Query $sql failed with error " . mysql_error());[/i] into the code, and came up with this error wich is within the function : [b]Query select bidfrom plepictures where id= failed with error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id=' at line 1[/b] and this is the page so you get an Idea http://www.okdesigns.org thanks for your help.
  6. [b]Hi there I have a problem with a function( i think is the function) don't pay attention to the noob code everything works except last part I'M NOT ABLE TO WRITE DATBASE (connected succesfully)[/b]     this is nothing real is homework but I been stuck in this part for 3 days, thanks for your help look at the last lines in bold that's what i think is wrong. <?php require_once ('db_connect.php'); if (isset ($_POST[submit])){ if (strlen ($_POST[name])>0) {$name = stripslashes ($_POST[name]);} else {$name = NULL; echo '<p><b>Your forgot to enter your name!!</b></p>' ;} if (strlen ($_POST[email])>0) {$email = stripslashes ($_POST[email]);} else {$email = NULL; echo '<p><b>Your forgot to enter eMail!!</b></p>' ;} if(strlen ($_POST[new_bid])>0) {$new_bid =($_POST[new_bid]);} else {$new_bid = NULL; echo '<p><b> Please place your bid!</b></p>';} if (($_POST[name]) && ($_POST[email] )&& ($_POST[new_bid])) ; { echo "Thank  you, <b>{$_POST[name]}</b> for bidding, we'll contact you at <b>{$_POST[email]}</b> if you win this item";} } else{ //displays form ?> <title>PLE1</title> <body bgcolor="#CCCCCC"><form action=" <?php echo $_SERVER['PHP_SELF']; ?>" method="post">        <fieldset style="border-color:#1A50B8 "><legend><font color="#1A50B8">Enter your information</font></legend> <p><b>Your name:</b> <input type="text" name="name" maxlength="40"></p> <p><b>Email:</b> <input type="text" name="email"  maxlength="25"></p> <b>Your Bid:</b>     <select name = "new_bid">       <option value="">Increase By</option>       <option value="10">US$10</option>       <option value="20">US$20</option>       <option value="30">US$30</option>       <option value="40">US$40</option>       <option value="50">US$50 </option>     </select>     <input type="submit" value="PlaceBid" name="submit"> </fieldset /form> <?php } ?> <table cellpadding="2" cellspacing="1" border="2" bordercolor="#000000"> <tr> <td bgcolor="666666"<b>Image</b></td> <td bgcolor="666666"<b>Description</b></td> <td bgcolor="666666"<b>Current Bid</b></td> <td bgcolor="666666"<b>Highest Bidder</b></td> <td bgcolor="666666"<b>Select</b></td> </tr> <?php $sql = 'select * from plepictures order by bid desc'; $result = @mysql_query($sql); while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) { echo   '<tr><td><img src = "'. $row['filename']. '"></td>' //file name working . '<td bgcolor="cccccc">'. $row['description'].'</td>'                // description working . '<td bgcolor="999999">US$'. $row['bid'].'</td>' //bid working . '<td bgcolor="666666">'. $row['name'].'</td>' //name working .'<td align = "center" bgcolor="000000"><input type = "radio" name = "image_id" value = '. $row['id'].'"></td></tr>'; } ?> </table> [b] <?php  //EVERYTHING UP TO HERE WORKS FINE DATABASE IS CONNECTED ETC. //THIS IS THE FUNCTION THAT's PROBABLY IS WRONG function increaseBid() {    $sql = "select bidfrom plepictures WHERE id=$image_id"; $result = @mysql_query($sql); $row = @mysql_fetch_array($result,MYSQL_ASSOC); $bid = $row[0] + $new_bid; mysql_query("UPDATE plepictures  SET bid='$bid', name='$name', email='$email', WHERE id='$image_id'"); } function getYear() {   $year = date("Y");   return $year; } if (isset ($_POST[submit])){ increaseBid();//<======================CALLED THE FUCTION printf ( mysql_affected_rows()); print("This year is: ".getYear()."\n"); ALL THIS IS SUPPOSED TO WORK BUT IT JUST WON'T CHANGE ANY VALUES IN MY PAGE [/b] } ?> NOW IF I CHANGE A VALUE IN THE DATABASE IS SHOWN IN THE PAGE, BUT I CAN'T MAKE IT WRITE THE DATABASE AND RETURN THE VALUES TO MY PAGE.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.