svgmx5 Posted November 15, 2009 Share Posted November 15, 2009 This is the second time i come here for this problem. This time i can't figure out why i'm getting the error, i'm hoping someone can help me narrow down the problem Here's the script <?php session_start(); if($_SESSION['log'] == TRUE) { include('../resources/config.php'); $tutorID= $_SESSION['tutor']; }else { echo"<script type='text/javascript'> window.location='login.php' </script>"; } $sql = "SELECT * FROM tutorProfiles WHERE tutor='$tutorID'"; $run = mysql_query($sql) or die(mysql_error()); $num = mysql_num_rows($run); while($fetch = mysql_fetch_assoc($run)) { $first = $fetch['first']; $username = $fetch['username']; } $sql = "SELECT * FROM email WHERE emailid={$_GET['emailID']}"; $run = mysql_query($sql) or die(mysql_error()); $num = mysql_num_rows($run); while($fetch = mysql_fetch_assoc($run)) { $emailID = $fetch['emailid']; $messageName = $fetch['name']; $messageEmail = $fetch['email']; $messageSubject = $fetch['subject']; $messageBody = $fetch['message']; } ?> <!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> <link href="../styles/profilestyle.css" rel="stylesheet" type="text/css" /> <link href="../../scripts/styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> <div id="logo"> </div> <div id="topLinks"> <ul> <li><? if($_SESSION['log']==TRUE) { echo"<a href='logout.php'> Log Out </a> Welcome Back $first "; } ?> </li> </ul> </div> <div id="navigation"> <ul> <li><a href="../../index.php">Find a Tutor</a></li> <li><a href="../../about.php">About Us</a></li> <li><a href="../../faq.php">F.A.Q</a></li> <li><a href="../../become.php">Join Us</a></li> <li><a href="../../contact.php">Contact</a></li> </ul> </div> </div> <div id="myacctBody"> <div id='topBox'> <table width="850" cellpadding="0" cellspacing="0" border="0" id="inboxDefault"> <tr> <td width="201" valign="top"> <ul class="inboxSideMenuDisplay"> <li> <a href="inbox.php?tutor=$tutorID"> <img src="../images/inbox.png" alt="inbox" width="30" height="25" border="0" />Inbox </a> </li> <li> <a href="editInfo.php?tutor=$tutorID"> <img src="../images/update.png" alt="update Acct" width="26" height="25" border="0" />Update Account </a> </li> <li> <a href="update.php?tutor=$tutorID"> <img src="../images/profile.png" alt="update Profile" width="31" height="26" border="0" />Edit Profile </a> </li> <li> <a href="index.php?tutor=$tutorID"> <img src="../images/controlPanel.png" alt="control panel" width="25" height="25" border="0" /> Return To Main </a> </li> </ul> </td> <td width="649" valign="top"> <div id="inboxBoxDefault"> <div class="inboxMessageBodyDisplay"> <div id="emailButtons"> <ul> <li class="replyButton"> <a href="replyMessage.php?messageID=$messageID"> <img src="../images/replymail.png" alt="reply" width="28" height="20" border="0" />Reply </a> </li> <li class="deleteButton"> <a href="deleteMessage.php?messageID=$messageID"> <img src="../images/deleteMail.png" alt="delete" width="30" height="20" border="0" /> Delete </a> </li> </ul> </div> <p><strong>From:</strong><?php echo"$messageEmail";?><br/> <strong>Full name:</strong><?php echo"$messageName";?><br/> <strong>Subject: </strong><?php echo"$messageSubject";?><br/> </p> <p><strong>Message:</strong></p> <?php echo "$messageBody"; ?> <div id="emailButtons"> <ul> <li class="replyButton"> <a href="#"> <img src="../images/replymail.png" alt="reply" width="28" height="20" border="0" />Reply </a> </li> <li class="deleteButton"> <a href="#"> <img src="../images/deleteMail.png" alt="delete" width="30" height="20" border="0" />Delete </a> </li> </ul> </div> </div> </div> </td> </tr> </table> </div> </div> <div id="footer"> <div id="copyInfo"> <p>Copy Right © 2009 Tutoring site, All Rights Reserved</p> </div> <div id="textLinks"> <ul> <li><a href="#">Find a Tutor</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Join Us</a></li> <li><a href="#">FAQ</a></li> <li><a href="#">Contact</a></li> </ul> </div> <div id="siteInfo"> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/181576-solved-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2009 Share Posted November 15, 2009 A) Which of the two possible queries are failing, B) Is emailid a string data type, which would mean that the value you are comparing with it would need to be enclosed in single-quotes, and C) Posting the actual error message would help. Quote Link to comment https://forums.phpfreaks.com/topic/181576-solved-you-have-an-error-in-your-sql-syntax/#findComment-957738 Share on other sites More sharing options...
svgmx5 Posted November 15, 2009 Author Share Posted November 15, 2009 my bad the error i get is this 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 What i have is a page before this one in which it lists all the messages in the database. Each item has a link to view the complete message. when the user clicks on the link they are sent to this page that i have to view the whole message. So in the previous page i have a link that looks like this <a href="viewMessage.php?emailid='.$emailID.'"> so i use {$_GET['emailID']} in the $sql command $sql = "SELECT * FROM email WHERE emailid={$_GET['emailID']}"; I hope that makes sense Quote Link to comment https://forums.phpfreaks.com/topic/181576-solved-you-have-an-error-in-your-sql-syntax/#findComment-957741 Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2009 Share Posted November 15, 2009 emailid in the URL ?emailid= is not the same as emailID in $_GET['emailID'] Quote Link to comment https://forums.phpfreaks.com/topic/181576-solved-you-have-an-error-in-your-sql-syntax/#findComment-957744 Share on other sites More sharing options...
svgmx5 Posted November 15, 2009 Author Share Posted November 15, 2009 sorry, i don't understand what you are saying Quote Link to comment https://forums.phpfreaks.com/topic/181576-solved-you-have-an-error-in-your-sql-syntax/#findComment-957751 Share on other sites More sharing options...
svgmx5 Posted November 15, 2009 Author Share Posted November 15, 2009 okay nevermind, i saw what you were saying got it to work thanks! Quote Link to comment https://forums.phpfreaks.com/topic/181576-solved-you-have-an-error-in-your-sql-syntax/#findComment-957752 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.