Author Topic: Reading Mysql Table Correctly  (Read 198 times)

0 Members and 1 Guest are viewing this topic.

Offline jnerotrixTopic starter

  • Enthusiast
    • View Profile
Reading Mysql Table Correctly
« on: December 08, 2008, 06:05:12 PM »
Its supposed to check if $memberid is in there and check if  $memberid matches member_id and if they match do not display that survey id

This is They Query i have so far but it doesnt do what i want it to do

Code: [Select]
$query = "select survey.id, survey.title, survey.adlink from survey left join completed_surveys on ( survey.id = completed_surveys.survey_id ) WHERE completed_surveys.survey_id IS NULL AND completed_surveys.member_id=$memberid";
and heres the whole code

Code: [Select]
<?php
mysql_connect
("localhost""sex1800_admin""12921993") or die(mysql_error()); //add you password
mysql_select_db("sex1800_loginbux") or die(mysql_error());

$memberid = (is_numeric($_GET['id'])) ? $_GET['id'] : 0;
$query "select survey.id, survey.title, survey.adlink from survey left join completed_surveys on ( survey.id = completed_surveys.survey_id ) WHERE completed_surveys.survey_id IS NULL AND completed_surveys.member_id=$memberid";
$result mysql_query($query) or die(mysql_error());
?>

Number Of Surveys Available = <?php echo mysql_num_rows($result); ?>

<?php
while($row mysql_fetch_array($result)){
echo 
"<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>";
}
?>

Offline shadiadiph

  • Devotee
    • View Profile
Re: Reading Mysql Table Correctly
« Reply #1 on: December 08, 2008, 06:58:01 PM »
here is one error i spotted straight away

Code: [Select]
WHERE completed_surveys.survey_id IS NULL AND
i think it should be 

Code: [Select]
WHERE completed_surveys.survey_id IS 'NULL' AND

 

Offline gevans

  • Addict
  • Gender: Male
  • don't shoot the messanger
    • View Profile
    • Purple Coffee Interactive
Re: Reading Mysql Table Correctly
« Reply #2 on: December 08, 2008, 07:12:21 PM »
NULL doesn't need quotes

it's like TRUE and FALSE
I like starting my code with session_start();

Code: [Select]
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
Son of a biscuit eating bulldog

Use [code][/code] tags!!

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.