Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. stick single quotes around each variable. something is causing the query to hit an escape character:

    if($exist_check == 0) {		
    //Adding data to the database...
    $sql = "INSERT INTO `quiz` (`id`, `quizId`, `quizTitle`, `managerId`, `userId`, `userIdRec`, `userGroup`, `egroup`, `userScore`, `totalScore`, `passScore`, `passState`, `Result`, `userDate`, `addDate`) ";
    $sql = $sql." VALUES (null, '".$quizId."', '".$quizTitle."', '".$managerId."', '".$userId."', '".$userIdRec."', '".$userGroup."', '".$egroup."', '".$userScore."', '".$totalScore."', '".$passScore."', '".$passState."', '".$strResults."', '".$postDate."', NOW())";
    }else{	
    //Adding data to the database...
    $sql = "UPDATE `quiz` SET `userScore` = '$userScore', `passState` = '$passState', `Result` = '$strResults', `userDate` = '$postDate', `addDate` = NOW()";
    $sql = $sql." WHERE `managerId` =' $managerId' AND `userIdRec` = '$userIdRec' AND `quizId` =' $quizId' AND `quizTitle` = $quizTitle ";
    }

  2. ok, I see what your saying now. Just to confirm what is getting passed in try and kill the script and echo out the sql to see what is being passed intto the query. that should give u a heads up:

    if($exist_check == 0) {		
    //Adding data to the database...
    $sql = "INSERT INTO `quiz` (`id`, `quizId`, `quizTitle`, `managerId`, `userId`, `userIdRec`, `userGroup`, `egroup`, `userScore`, `totalScore`, `passScore`, `passState`, `Result`, `userDate`, `addDate`) ";
    $sql = $sql." VALUES (null, '".$quizId."', '".$quizTitle."', '".$managerId."', '".$userId."', '".$userIdRec."', '".$userGroup."', '".$egroup."', '".$userScore."', '".$totalScore."', '".$passScore."', '".$passState."', '".$strResults."', '".$postDate."', NOW())";
    }else{	
    //Adding data to the database...
    $sql = "UPDATE `quiz` SET `userScore` = $userScore, `passState` = $passState, `Result` = $strResults, `userDate` = $postDate, `addDate` = NOW()";
    $sql = $sql." WHERE `managerId` = $managerId AND `userIdRec` = $userIdRec AND `quizId` = $quizId AND `quizTitle` = $quizTitle ";
    }
    die($sql);
    

     

  3. Ok, even if your update is failing it should return something so

    $rs

    will always be true.

    Try this:

    if (last_insert_id()!= 0) {
      echo "feedMsg=Data has been posted successfully";	
      }
    else {
      echo "feedMsg=Failed to post data to database";
    }

     

    that will return the id of the last row affected ( as long as the primary key is auto incrimented)

  4. remove the brackets:

    $sql = "UPDATE `quiz` SET `userScore` = $userScore, `passState` = $passState, `Result` = $strResults, `userDate` = $postDate, `addDate` = NOW()";
    $sql = $sql." WHERE `managerId` = $managerId AND `userIdRec` = $userIdRec AND `quizId` = $quizId AND `quizTitle` = $quizTitle ";

  5. I thought I was [pretty clear in my last post, but I'm not one the leave someone stranded lol. So here you go.

    Firstly left click on on the wamp icon in your system tray and select php from the menu, then php.ini from the sub menu:

    See attachment.

     

    this will open up the php.ini file in notepad. use control + F to search the document and search for [mail function]. This should show you the mail section of the document:

    [mail function]

    ; For Win32 only.

    ; http://php.net/smtp

    SMTP = localhost

    ; http://php.net/smtp-port

    smtp_port = 25

     

    change this to whatever your isp's outgoing mail server is:

     

    [mail function]

    ; For Win32 only.

    ; http://php.net/smtp

    SMTP = smtp.bt.com

    ; http://php.net/smtp-port

    smtp_port = 25

     

     

    save the file and restart your wamp

     

     

    [attachment deleted by admin]

  6. I presume you are talking about using clean urls.

     

    To do this you will need to ensure your server has the mod rewrite module enabled. Then all you need to do is add or alter your existing .htaccess file to allow for the modification:

     

    add these into the .htaccess:

     

    RewriteEngine On
    RewriteRule ^([a-z]+)/([a-z\-]+)$ /$1/$2.php [L]
    

     

    hope that helps get you started :)

  7. You probably havent set up your outgoing mail server on your localhost. I can see from your error you are on a windows machine using wamp.  What you need to do is amend your php.ini file to allow for smtp(simple mail transfer protocol - outgoing mail). If you find your php.ini, look for SMTP. It will most likely be set to localhost ( smtp=localhost). Change this to your ISP's outgoing mail server address : i.e smtp.bt.com.

     

    Secondly search for smtp_port and make sure it says smtp_port = 25.

     

    restart your apache and retry.

     

    good luck

     

     

  8. The headers already sent error can be caused having white space (extra blank spaces before or after the opening and closing PHP tags.

    (<?php  ?>)

    all headers should generally be placed at the top of the page to avoid this. Also if you have included another file that is declaring a header before line 15 then that will cause a problem.

  9. What you are doing is attempting to pass a GET parameter through the url. This is done using the following syntax:

     

    <?php
    $id = '1224';
    <a href="http://www.somesite.com/somepage.php?id=$id"></a>
    // you can append as many variables as you need. These have to be seperated by the & sign.
    <a href="http://www.somesite.com/somepage.php?id=$id&id2=$id2.........."></a>
    

    then on the page you are sending the variables to:

    $id = $_GET['id];

  10. its more than likely because the sql is in a loop and referencing the same sql connection. try:

    <?php
    require_once('auth.php');
    ?>
    <?php $id = $_SESSION['SESS_MEMBER_ID'] ?>
    <html>
    <head>
    <title>Announcement</title>
    </head>
    <body>
    
    <table border="0" width="100%" height="100%">
    
    <tr height="15%">
    <td colspan="5"><?php include "header.php"; ?></td>
    </tr>
    
    <tr> 
    
    <td>
    
    <table border="0" width="100%" height="100%">
    
    <tr>
    <td width="25%" valign="top"><div valign="top"><?php include "menu.php"; ?></div></td>
    <td width="50%" valign="top"><center>
    <center><div class="subheading"><b>All Networks</b></div></center>
    
    <?php
    
    $host="1*2.*0.1*3.2*"; // Host name 
    $username="martin9t9"; // Mysql username 
    $password="***"; // Mysql password 
    $db_name="martin9t9"; // Database name 
    $tbl_name="post"; // Table name 
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect server "); 
    
    $sql="SELECT * FROM martin9t9.$tbl_name ORDER BY id DESC";
    $result=mysql_query($sql);
    $i = 0;
    while($rows=mysql_fetch_array($result)){
    ?>
    
    <table border="0" width="100%">
    
    <tr>
    <td rowspan="2" width="45" height="45"> </td>
    <td colspan="2"><a href="view-profile.php?uid=<?php echo $rows['uid'] ?>" class="postname"><? echo $rows['first']; ?> <? echo $rows['last']; ?></a> on <a class="postname"><? echo $rows['network']; ?></a></td>
    </tr>
    <?php $network = $rows['network']; $postid = $rows['id']; ?>
    <tr>
    <td><div class="post"><? echo $rows['post']; ?></div></td>
    <td width="45"></td>
    </tr>
    
    <tr>
    <td colspan="3" class="text" align="right"> 
    
    <?php 
      if($rows['user'] !== $_SESSION['SESS_USER']) {
      echo '<a href="like-exec.php?postid=' . $rows['id'] . '&url=member-index.php"><img src="resources/tick.png" alt="Like" border="0"></img></a><font class="like"> '; 
      
    
    $sql.$i="SELECT SUM(yes) as total FROM martin9t9.rating WHERE postid='$postid'";
    $result.$i=mysql_query($sql.$i);
    
    while($rows.$i=mysql_fetch_array($result.$i)){
    
    echo $rows.$i['total']; 
    
    }
    mysql_close(); //close database 
      
       
    echo   '</font> - <a href="dislike-exec.php?postid=' . $rows.$i['id'] . '&url=member-index.php&like=' . $rows.$i['no'] . '"><img src="resources/cross.png" alt="Dislike" border="0"></img></a> <font class="dislike"> ' . $rows.$i['no'] . '</font>'; 
    }    else {
      echo '<font class="like"> ' . $rows.$i['yes'] . '</font> - <font class="dislike"> ' . $rows.$i['no'] . '</font>'; 
    ?>
    
    </td>
    
    </tr>
    
    </table>
    <hr color="#F0F0F0">
    <?
    }}
    mysql_close(); //close database
    ?>
    
    
    </center></td>
    <td width="25%"></td>
    </tr>
    
    </table>
    
    </td>
    
    </tr>
    
    </table>
    
    </body>
    </html>
    

  11. line 62. youve got a concatenator on the end of the line. should be:

      echo '<a href="like-exec.php?postid=' . $rows['id'] . '&url=member-index.php"><img src="resources/tick.png" alt="Like" border="0"></img></a><font class="like"> '; 

  12. you had opened , and not closed a set of brackets, also you had an echo missing:

    <?php
    require_once('auth.php');
    ?>
    <?php $id = $_SESSION['SESS_MEMBER_ID'] ?>
    <html>
    <head>
    <title>Announcement</title>
    </head>
    <body>
    
    <table border="0" width="100%" height="100%">
    
    <tr height="15%">
    <td colspan="5"><?php include "header.php"; ?></td>
    </tr>
    
    <tr> 
    
    <td>
    
    <table border="0" width="100%" height="100%">
    
    <tr>
    <td width="25%" valign="top"><div valign="top"><?php include "menu.php"; ?></div></td>
    <td width="50%" valign="top"><center>
    <center><div class="subheading"><b>All Networks</b></div></center>
    
    <?php
    
    $host="***"; // Host name 
    $username="***"; // Mysql username 
    $password="***"; // Mysql password 
    $db_name="***"; // Database name 
    $tbl_name="post"; // Table name 
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect server "); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $sql="SELECT * FROM database1.$tbl_name ORDER BY id DESC";
    $result=mysql_query($sql);
    
    while($rows=mysql_fetch_array($result)){
    ?>
    
    <table border="0" width="100%">
    
    <tr>
    <td rowspan="2" width="45" height="45"> </td>
    <td colspan="2"><a href="view-profile.php?uid=<?php echo $rows['uid'] ?>" class="postname"><? echo $rows['first']; ?> <? echo $rows['last']; ?></a> on <a class="postname"><? echo $rows['network']; ?></a></td>
    </tr>
    <?php $network = $rows['network']; $postid = $rows['id']; ?>
    <tr>
    <td><div class="post"><? echo $rows['post']; ?></div></td>
    <td width="45"></td>
    </tr>
    
    <tr>
    <td colspan="3" class="text" align="right"> 
    
    <?php 
      if($rows['user'] !== $_SESSION['SESS_USER']) {
      echo '<a href="like-exec.php?postid=' . $rows['id'] . '&url=member-index.php"><img src="resources/tick.png" alt="Like" border="0"></img></a><font class="like"> ' . 
      
    
    $sql2="SELECT SUM(yes) as total FROM database2.$tbl_name1 WHERE postid='$postid'";
    $result2=mysql_query($sql2);
    
    while($rows=mysql_fetch_array($result2)){
    
    echo $rows['total']; 
    
    }
    mysql_close(); //close database 
      
       
    echo   '</font> - <a href="dislike-exec.php?postid=' . $rows['id'] . '&url=member-index.php&like=' . $rows['no'] . '"><img src="resources/cross.png" alt="Dislike" border="0"></img></a> <font class="dislike"> ' . $rows['no'] . '</font>'; 
    }    else {
      echo '<font class="like"> ' . $rows['yes'] . '</font> - <font class="dislike"> ' . $rows['no'] . '</font>'; 
    ?>
    
    </td>
    
    </tr>
    
    </table>
    <hr color="#F0F0F0">
    <?
    }}
    mysql_close(); //close database
    ?>
    
    
    </center></td>
    <td width="25%"></td>
    </tr>
    
    </table>
    
    </td>
    
    </tr>
    
    </table>
    
    </body>
    </html>
    
    

  13. <?php
    require_once('auth.php');
    ?>
    <?php $id = $_SESSION['SESS_MEMBER_ID'] ?>
    <html>
    <head>
    <title>Announcement</title>
    </head>
    <body>
    
    <table border="0" width="100%" height="100%">
    
    <tr height="15%">
    <td colspan="5"><?php include "header.php"; ?></td>
    </tr>
    
    <tr> 
    
    <td>
    
    <table border="0" width="100%" height="100%">
    
    <tr>
    <td width="25%" valign="top"><div valign="top"><?php include "menu.php"; ?></div></td>
    <td width="50%" valign="top"><center>
    <center><div class="subheading"><b>All Networks</b></div></center>
    
    <?php
    
    $host="***"; // Host name 
    $username="***"; // Mysql username 
    $password="***"; // Mysql password 
    $db_name="***"; // Database name 
    $tbl_name="post"; // Table name 
    
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect server "); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $sql="SELECT * FROM database1.$tbl_name ORDER BY id DESC";
    $result=mysql_query($sql);
    
    while($rows=mysql_fetch_array($result)){
    ?>
    
    <table border="0" width="100%">
    
    <tr>
    <td rowspan="2" width="45" height="45"> </td>
    <td colspan="2"><a href="view-profile.php?uid=<?php echo $rows['uid'] ?>" class="postname"><? echo $rows['first']; ?> <? echo $rows['last']; ?></a> on <a class="postname"><? echo $rows['network']; ?></a></td>
    </tr>
    <?php $network = $rows['network']; $postid = $rows['id']; ?>
    <tr>
    <td><div class="post"><? echo $rows['post']; ?></div></td>
    <td width="45"></td>
    </tr>
    
    <tr>
    <td colspan="3" class="text" align="right"> 
    
    <?php 
      if($rows['user'] !== $_SESSION['SESS_USER']) 
      echo '<a href="like-exec.php?postid=' . $rows['id'] . '&url=member-index.php"><img src="resources/tick.png" alt="Like" border="0"></img></a><font class="like"> ' . 
      
    
    
    
    
    $sql2="SELECT SUM(yes) as total FROM database2.$tbl_name1 WHERE postid='$postid'";
    $result2=mysql_query($sql2);
    
    while($rows=mysql_fetch_array($result2)){
    
    echo $rows2['total']; 
    
    }
    mysql_close(); //close database 
      
      
        '</font> - <a href="dislike-exec.php?postid=' . $rows2['id'] . '&url=member-index.php&like=' . $rows2['no'] . '"><img src="resources/cross.png" alt="Dislike" border="0"></img></a> <font class="dislike"> ' . $rows2['no'] . '</font>'; 
      else 
      echo '<font class="like"> ' . $rows['yes'] . '</font> - <font class="dislike"> ' . $rows2['no'] . '</font>'; 
    ?>
    
    </td>
    
    </tr>
    
    </table>
    <hr color="#F0F0F0">
    <?
    }
    mysql_close(); //close database
    ?>
    
    
    </center></td>
    <td width="25%"></td>
    </tr>
    
    </table>
    
    </td>
    
    </tr>
    
    </table>
    
    </body>
    </html>
    
    

     

    dont forget to replace database1 and database2 with whatever your databases are called

×
×
  • 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.