Jump to content

Alex1646

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by Alex1646

  1. Ive checked my db and the values in the optional fields are not getting inserted,
  2. Sense php is server side, it only gets updated when the browser calls for the page. This is because the PHP gets interpreted in the server not the browser. I am pretty sure Javascript that can let you refresh when something happens.
  3. I am trying to create a script that takes information from a form and puts in a database. In the action page, I decided to post a URL that shows the user there story that they posted. This is where I ran into the problem. . I realized that for the optional fields I could not just use a seperate insert statement, because this creates a new row. So I desided to use update statments, but this STILL does not work, they values or simply not getting inserted. Here is the code: <?php if(isset($_POST['hidden'])) { die('SPAM BOT!'); } if ( !isset($_POST['title']) && !isset($_POST['summary']) && !isset($_POST['story']) && !isset($_POST['rating']) && !isset($_POST['cat']) ) { die("<div id='impor'>You forgot to enter one(or more) of the following fields <br /> 1. Title <br /> 2. Summary <br /> 3. Story<br /> </div> "); } mysqlConnect(); //take data from form an\ put them in variable $title_form = bb(mysql_real_escape_string($_POST['title'])); //required $summ_form = bb(mysql_real_escape_string($_POST['summary']));// required $story_form = bb(mysql_real_escape_string($_POST['story'])); $cat_form = $_POST['cat']; $rating_form = $_POST['rating']; $username = $_SESSION['user']; // Make the other var into a list of links mysql_query(" INSERT INTO story_info (title, sum, story, user, cat, rating) VALUES('$title_form','$summ_form', '$story_form,', '$username', '$cat_form','$rating_form') "); if(isset($_POST['notes'])) { $notes_form = mysql_real_escape_string($_POST['notes']); $notes_final = bb($notes_form); mysql_query(" UPDATE story_info SET notes = '$notes_final' WHERE story = '$story_form' AND user = '$username' AND sum = '$summ_form' AND title = '$title_form' "); } //put other in array. Use while loop to put link code. Then but it back into one non array variable if(isset($_POST['u_id'])) { $uid = mysql_real_escape_string($_POST['u_id']); $uid_db = str_replace(' ','_', $uid); $blerg = " UPDATE story_info SET series_id = '$uid_db' WHERE story = '$story_form' AND user = '$username' AND sum = '$summ_form' AND title = '$title_form' "; mysql_query($blerg); } echo "<h1> Your Story Has Been Posted! Thanks for posting $username . </h1>"; echo "Please review the post below <br />"; echo "<h2> $title_form </h2>"; echo "<strong> <h2> Summary: </h2> </strong> $summ_form"; echo "<h4> Story: </h4>"; echo "$story_form"; if(isset($notes)) { echo "<h4> Author's Notes: </h4> "; echo "$notes_final"; } if (isset($uid_db)) { echo '<h3> Unique Series ID </h3>'; echo '<p> Make sure to write down this! <br />' .$uid_db .'</p> '; } $db = mysql_query(" SELECT story_id FROM story_info WHERE story='$story_form' AND user='$username' ")or die(mysql_error()); $rows = mysql_fetch_assoc($db); $id = $rows['story_id']; echo "Catagory: $cat_form <br /> Rating: $rating_form <br /> "; echo "<a href='?p=page&id=$id'> Click here to view your story! </a>'"; ?> Please help!
  4. Ok. I never did get my insert question answered. But I did figure out whats wrong, when I use another insert statement it creates a new row. I tryed using UPDATE but it doesnt seem to work. Im going to start a new thread on this.
  5. I ended up getting no rows found, but this confuses me. I thought I just inserted the data.
  6. Here is the whole code if you need it. <?php if(isset($_POST['hidden'])) { die('SPAM BOT!'); } if ( !isset($_POST['title']) && !isset($_POST['summary']) && !isset($_POST['story']) && !isset($_POST['rating']) && !isset($_POST['cat']) ) { die("<div id='impor'>You forgot to enter one(or more) of the following fields <br /> 1. Title <br /> 2. Summary <br /> 3. Story<br /> </div> "); } mysqlConnect(); //put notes in story if they are set if(isset($_POST['notes'])) { $notes_form = mysql_real_escape_string($_POST['notes']); $notes_final = bb($notes_form); mysql_query(" INSERT INTO story_info(notes) VALUES ('$notes_final') "); } //put other in array. Use while loop to put link code. Then but it back into one non array variable if(isset($_POST['u_id'])) { $uid = mysql_real_escape_string($_POST['u_id']); $uid_db = str_replace(' ','_', $uid); $blerg = " INSERT INTO story_info(series_id) VALUES('$uid_db') "; mysql_query($blerg); } //take data from form an\ put them in variable $title_form = bb(mysql_real_escape_string($_POST['title'])); //required $summ_form = bb(mysql_real_escape_string($_POST['summary']));// required $story_form = bb(mysql_real_escape_string($_POST['story'])); $cat_form = $_POST['cat']; $rating_form = $_POST['rating']; $username = $_SESSION['user']; // Make the other var into a list of links mysql_query(" INSERT INTO story_info (title, sum, story, user, cat, rating) VALUES('$title_form','$summ_form', '$story_form,', '$username', '$cat_form','$rating_form') "); echo "<h1> Your Story Has Been Posted! Thanks for posting $username . </h1>"; echo "Please review the post below <br />"; echo "<h2> $title_form </h2>"; echo "<strong> <h2> Summary: </h2> </strong> $summ_form"; echo "<h4> Story: </h4>"; echo "$story_form"; if(isset($notes)) { echo "<h4> Author's Notes: </h4> "; echo "$notes_final"; } if (isset($uid_db)) { echo '<h3> Unique Series ID </h3>'; echo '<p> Make sure to write down this! <br />' .$uid_db .'</p> '; } $db = mysql_query(" SELECT story_id FROM story_info WHERE story='$story_form' AND user='$username' ")or die(mysql_error()); $rows = mysql_fetch_assoc($db); $id = $rows['story_id']; echo "Catagory: $cat_form <br /> Rating: $rating_form <br /> "; echo "<a href='?p=page&id=$id'> Click here to view your story! </a>'"; ?>
  7. Well, the ID variable is simply not getting defined. When I insert the $rows = mysql_fetch_assoc($db) or die(mysql_error()); code, It does DIE but there is no message from mysql_error()
  8. Here is the code: <?php $db = mysql_query(" SELECT story_id FROM story_info WHERE story='$story_form' AND user='$username' ")or die(mysql_error()); $rows = mysql_fetch_assoc($db); $id = $rows['story_id']; ?> All of the variables are defined earlier in the code.
  9. $id_get is defined at the begining of the page. There is a lot more code to display the story. But the id_get is the id of the story. As the var name tells it is a get variable. First one: Notice: Undefined variable: ratav in C:\wamp\www\Login\inc\page.php on line 115 Second One: Warning: array_sum() expects parameter 1 to be array, null given in C:\wamp\www\Login\inc\page.php on line 116 Third One: Notice: Undefined variable: ratav in C:\wamp\www\Login\inc\page.php on line 117 Here is the rest of the code if needed: <?php $id_get = $_GET['id']; //grab data from db mysqlConnect(); //query***************************************************** $query1 = " SELECT * FROM story_info WHERE story_id = '$id_get' "; $select = mysql_query($query1) or die(mysql_error()); $rows1 = mysql_fetch_assoc($select); //put data into vars $titledb = $rows1['title']; $sumdb = $rows1['sum']; $notesdb = $rows1['notes']; $storydb = $rows1['story']; $otherdb = $rows1['other']; $userdb = $rows1['user']; $catdb = $rows1['cat']; $ratingdb = $rows1['rating']; //take data from user_info table //query***************************************************** $query2 = " SELECT * FROM login_info WHERE user='$userdb' "; $select2 = mysql_query($query2) or die(mysql_error()); $rows2 = mysql_fetch_assoc($select2); //take data from table $id_db = $rows2['id']; $profile_db = $rows2['profile_picture']; ?> <div class='story'> <h2> <?php echo $titledb; ?> </h2> <?php echo $storydb?> </div> <div class='story_info'> <img src="<?php echo $profile_db;?>" width="172" height="166" /> <br /> <a href="http://scribofabula.com/soc?p=profile&pid=<?php echo $profile_db; ?>"> <?php echo $userdb; ?> </a> ><br /> <h3> Summary </h3> <?php echo $sumdb; ?> <h3>Catagory/Genre:</h3> <a href='http://scribofabula.com/soc?p=cat_view&gen=<?php echo $catdb ?>'> <?php echo $catdb; ?> </a> </p> <h3>Rating:</h3> <?php echo $ratingdb; ?> <?php if (isset($notesdb)) { echo "<h3> Author's Notes: </h3>"; echo $notesdb; } ?> <?php echo "<h3> Other Stories</h3>"; echo $otherdb; ?> </div> <br/> <div class='com'> <h2> Reviews: </h2> <?php $query3 = " SELECT * FROM story_commets WHERE story = '$id_get' ORDER BY date_added "; $select3 = mysql_query($query3) or die(mysql_error()); $x=1; while($rows3 = mysql_fetch_assoc($select3)) { $commetdb = $rows3['commet']; $user_com_db = $rows3['user']; $datedb = $rows3['date_added']; $stardb = $rows3['star']; //get profile picture $query4 = " SELECT * FROM story_commet WHERE user = '$user_com_db' "; $select4 = mysqli_query($dbc, $query4); $rows4 = mysqli_fetch_array($select4); $profile_pic = $rows4['profile_pic']; $user_id = $rows4['id']; echo " <div class='com_info'> <img src='$profile_pic' width='600' height='568' /> <br /> <a href='http://scribofabula.com/soc?p=profile&id=$user_id'> $user_com_id </div> <br /> $datedb <br /> </div> Rating: $stardb/10 <br /> $commetdb "; $ratav[$x]=$stardb; $x++; } $a=1; /* while($a>$array_num) { $ratav_final = array (); $a++; $ratav_final[$a] = $ratav[$a]; } */ print_r($ratav); $sum = array_sum($ratav); $count = count($ratav); $av = $sum * $count; echo"<div id='message'> Rating Avarage: $av /10 </div>"; if (isset($_SESSION['user'])) { echo' <p> Did you like this story? Did you hate it? Give it a rating and let the author know!</p> <form action="commet_res" method="post" enctype="multipart/form-data" target="_self"> <label> Your rating is on a scale of 1-10 </label> <select name="rat"> <option> 1 </option> <option> 2 </option> <option> 3 </option> <option> 4 </option> <option> 5 </option> <option> 6 </option> <option> 7 </option> <option> 8 </option> <option> 9 </option> <option> 10 </option> </select> <label> Commets: </label> <textarea name="commet" cols="70" rows="9"></textarea> </form> '; } else { echo "<div id='message'> Sign in to post a review! </div>"; } ?>
  10. In my website I want to have a rating system of stoires. I also want to avarage out the ratings (there on a scale of 1-10). I am putting all of my ratings in a array but it doesnt seem to be working. EVerytime I call the array I get a undefined error thingy. $query3 = " SELECT * FROM story_commets WHERE story = '$id_get' ORDER BY date_added "; $select3 = mysql_query($query3) or die(mysql_error()); $x=1; while($rows3 = mysql_fetch_assoc($select3)) { $commetdb = $rows3['commet']; $user_com_db = $rows3['user']; $datedb = $rows3['date_added']; $stardb = $rows3['star']; //get profile picture $query4 = " SELECT * FROM story_commet WHERE user = '$user_com_db' "; $select4 = mysqli_query($dbc, $query4); $rows4 = mysqli_fetch_array($select4); $profile_pic = $rows4['profile_pic']; $user_id = $rows4['id']; echo " <div class='com_info'> <img src='$profile_pic' width='600' height='568' /> <br /> <a href='http://scribofabula.com/soc?p=profile&id=$user_id'> $user_com_id </div> <br /> $datedb <br /> </div> Rating: $stardb/10 <br /> $commetdb "; $ratav[$x]=$stardb; $x++; }
  11. Ive been having trouble. Im getting this error: $select = mysql_query($query1); echo $select; $rows1 = mysqli_fetch_array($dbc, $select); I dont understand whats wrong.
  12. I'm creating a website where writers can share stories. I have a section where the users enter a summary of there story. Anyways in the area where the story in being listed I want the the title of the story(with a link to the story) underneath the link I would like a summary. BUUUUT, the summary can get pretty long(up to 900 chars). So I am wondering if I can shorten the variable where the summary is stored, I want it to be shorten to a fixed amount of characters(maybe 200?) then followed by a ... . So how can I do this?
  13. I am making a website where writers can share stories. One of the fields is other stories. So I used this code to make it a array with the links in each f the items. $other_split = explode(',', $other_form); $other_int = count($other_split); $x = 0; while ($x>$other_int) { $other_link[$x] = "<a href = '$other_split[$x]'> Chapter $x </a>"; } How can I insert the data in that array into one non array variable.
  14. Im looking for a BB CODE script. I just want a code for a function that I can run my user data through. Any help?
  15. I want information in a SQL database to delete automatically after specified time. How can I do this?
  16. There is no space in the file name. The file is called 'inc' without the quotes. I keep getting the same error.
  17. Im trying to create a php template. What I want to do is take in GET data saying what page I am on, then include that in the template. THe trouble is I cant get the damn thing to work, it keeps saying the file does not exist! Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div class="content"> <?php $page = $_GET['page']; $path = '/inc ' .$page .".php"; if(!isset($page)) { die('No Page Specified'); } if (file_exists($path)) { include($path); } else { die('Does not exsist!'); } ?> </div> </body> </html>
  18. I get this errr message Notice: Undefined index: user in C:\wamp\www\Login\login.php on line 25 Here is line 25: $_SESSION['user'] == $form_username ; Here is the whole page. <?php session_start(); ?> <html> <head> <title>Login</title> <?php include('logic.inc'); ?> </head> <body> <?php if (!isset($_POST['user_name']) && isset($_POST['password'])) { die("Please enter both a username and password"); } $form_username = $_POST['user_name']; $form_password = $_POST['password']; mysqlConnect(); loginvar(); if($passdb = $form_password && $userdb = $form_username) { $_SESSION['user'] == $form_username ; echo "<hr />"; echo "Login Sucssesful <br /> "; echo '<a href="/login/index.php">Return Home</a>'; } else { die("User name does not match password"); } ?> </body> </html> Hellp!
×
×
  • 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.