Jump to content

YMYL

New Members
  • Posts

    7
  • Joined

  • Last visited

YMYL's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I had a quick question on this. Would you use it for an integer? Lets say $page = $_GET['page']; Would you run mysql_real_escape_string($page) since it is data from the user? I checked and it returns an string, would that mess things up with a script?
  2. I'm trying to build a page that fetches information from a database: $result2 = $conn->query("select * from votes where pollid='$id'"); for ($count = 0; $row = $result2->fetch_row(); ++$count) { echo $row[2].' Votes:'.$row[3]."<BR>"; } However, the information is needed twice. Once for the CSS portion of the page, and the other for the html page. I can do this with one query but is it possible to do this with one query? I'm thinking this would be best for sever load.
  3. YMYL

    code problem

    OK this is very odd. I just added else{echo 'no';} And it looks like 1) isset is properly detecting that the variables aren't set 2) #4 and #8 are properly accounted for in the loop. Any idea why this might be?
  4. Hi all I'm having trouble with the code displayed below. The output I get after running it is answer1yesanswer2yesanswer3yesanswer5yesanswer6yesanswer7yes when I run it without any filler for the $answer variables. My question to you is 1) Why isset not working? 2) Why does it go 1-2-3-5-6-7 (skip 4 and ? Thank you for your time. --------- <?php require_once('functions.php'); session_start(); check_valid_user(); $question = $_POST['question']; $answer1 = $_POST['answer1']; $answer2 = $_POST['answer2']; $answer3 = $_POST['answer3']; $answer4 = $_POST['answer4']; $answer5 = $_POST['answer5']; $answer6 = $_POST['answer6']; $answer7 = $_POST['answer7']; $answer8 = $_POST['answer8']; $user = $_SESSION['valid_user']; $conn = db_connect(); //if (!$conn->query("insert into polls values (DEFAULT, '$question', '$user')")) //throw new Exception('Bookmark could not be inserted.'); //$insertid = mysqli_insert_id($conn); for ($i = 1; $i < 9; $i++) { $a = answer; $b = $a.$i; $c = $$b; if(isset($$B)) { echo $b; echo 'yes'; //if (!$conn->query("insert into votes values (DEFAULT, '$insertid', '$c',0)")) //throw new Exception('vote could not be inserted.'); } } ?>
  5. I have a form taking up to 8 answers. If an answer field is filled out, it will require a MySQL row insertion. What is the most elegant way to do this?
  6. why not combine a table for possible answers and answers given? also what would a table for polls look like? I understand a table for questions Thanks
  7. Hi all I'm a newbie working on my first decently sized project. Right now I'm trying to build a hosted poll script. Visitors to the site would be able to signup and build polls. I can user registration down, it's just that I have no idea how to structure the database. I was thinking about doing one table for each poll, but that would soon be unwieldy. Any help would be greatly appreciated. Thanks
×
×
  • 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.