Jump to content

bravo14

Members
  • Posts

    296
  • Joined

  • Last visited

Everything posted by bravo14

  1. cracked it, I hadn't made the field long enough. Thanks again for your help
  2. Many thanks for that, however I am still getting the same message. <?php session_start(); include_once('includes/connector.php'); if($_POST['submit']) { foreach ($_POST as $key => $val) { $$key = mysql_real_escape_string($val); } //is the email already registered? $user = mysql_query("SELECT username FROM `tbl_admin_users` WHERE username='$username'"); //Added single quotes around $email if(mysql_num_rows($user) > 0) //login name was found { //is the password correct $checkpassword = mysql_query("SELECT username FROM `tbl_admin_users` WHERE username='$username' and password=md5('$password')"); //Again added single quotes if(mysql_num_rows($checkpassword) > 0)//password is correct { $_SESSION['auth']="yes"; $_SESSION['logname'] = $username; //Just use $email here header("Location: index.php"); exit; //You should have an exit after a header('Location') } else //password is incorrect { $message="The email, '$email' exists, but you have not entered the correct password! Please try again.<br>"; } } else // username not found { $message = "The Login Name you entered does not exist! Please try again.<br>"; } } //Another brace was missing here ?> <!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="../style/2008.css" rel="stylesheet" type="text/css" /> </head> <body> <form name="login" method="post" action="login.php" onsubmit="return checkform()"> <table> <?php if (isset($message)) { echo "<tr><td style='color: red' colspan='2' align='center'>$message <br /></td></tr>"; } ?> <tr> <td>Username:</td><td><input name="username" type="text" size="30" /></td></tr> <tr><td>Password:</td><td><input name="password" type="password" size="30" /></td></tr> <tr><td><input type="hidden" name="submit" id="hiddenField" value="1"/></td> <td><input name="login2" type="submit" value="Login" class="button" /></td> </tr> </table> </form> </body> </html>
  3. Hi all I have a login form and script using md5 encryption, I know I have entered the correct password but I get a message saying the password I have entered is incorrect the code is below <?php session_start(); include_once('includes/connector.php'); //Just include the connector at the top if($_POST['submit']) //Added quotes around submit and removed = 1 { foreach ($_POST as $key => $val) { $$key = mysql_real_escape_string($val); //This is a huge security hole, as it allows people to inject variables into your code } //This was one missing brace //is the email already registered? $user = mysql_query("SELECT username FROM `tbl_admin_users` WHERE username='$username'"); //Added single quotes around $email if(mysql_num_rows($user) > 0) //login name was found { //is the password correct $password = mysql_query("SELECT username FROM `tbl_admin_users` WHERE username='$username' and password=md5('$password')"); //Again added single quotes if(mysql_num_rows($password) > 0)//password is correct { $_SESSION['auth']="yes"; $_SESSION['logname'] = $email; //Just use $email here header("Location: index.php"); exit; //You should have an exit after a header('Location') } else //password is incorrect { $message="The email, '$email' exists, but you have not entered the correct password! Please try again.<br>"; } } else // username not found { $message = "The Login Name you entered does not exist! Please try again.<br>"; } } //Another brace was missing here ?> <!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="../style/2008.css" rel="stylesheet" type="text/css" /> </head> <body> <form name="login" method="post" action="login.php" onsubmit="return checkform()"> <table> <?php if (isset($message)) { echo "<tr><td style='color: red' colspan='2' align='center'>$message <br /></td></tr>"; } ?> <tr> <td>Username:</td><td><input name="username" type="text" size="30" /></td></tr> <tr><td>Password:</td><td><input name="password" type="password" size="30" /></td></tr> <tr><td><input type="hidden" name="submit" id="hiddenField" value="1"/></td> <td><input name="login2" type="submit" value="Login" class="button" /></td> </tr> </table> </form> </body> </html> Any ideas where I have gone wrong? Mark
  4. I have the following erorr when I access a page, I cannot see an error, but I may be blind to it all Parse error: syntax error, unexpected $end in /home/sites/bravo14.co.uk/public_html/quantumphones/login.php on line 153 <?php session_start(); if($_POST[submit]=1) { foreach ($_POST as $key => $val) { $$key = mysql_real_escape_string($val); include_once('includes/connector.php'); //is the email already registered? $user =mysql_query('SELECT email FROM `tbl_customers` WHERE email=$email'); if(mysql_num_rows($user) > 0) //login name was found { //is the password correct $password = mysql_query('SELECT email FROM `tbl_customers` WHERE email=$email and password=md5("$password")'); if(mysql_num_rows($password) > 0)//password is correct { $_SESSION['auth']="yes"; $logname=$email; $_SESSION['logname'] = $logname; header("Location:account/index.php"); } else //password is incorrect { $message="The email, '$email' exists, but you have not entered the correct password! Please try again.<br>"; } } elseif ($user == 0) // email not found { $message = "The Login Name you entered does not exist! Please try again.<br>"; } ?> <!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>Quantum Phones</title> <?php include_once ('includes/meta.php'); ?> <script language="javascript"> <script language="javascript"> function popupwin() winpopup=window.Open('','popup','height=500,width=400,menubar=no,scrollbars=vertical,status=no,toolbar=no,screenX=100,screenY=0,left=100,top=0'); } </script> function checkform() var message="";//blank error message string //Test email length if (document.login.email.value.length==0) { message=message+"Please enter the registered email address\n";} //Test the password if (document.login.password.value.length==0) { message=message+"Please enter your password";} if(message.length > 0) {//is there an error message? alert(message);//displays error message return false;//return bad, not ok to process } else{ return true;//no error message } } </script> <link href="style/shop.css" rel="stylesheet" type="text/css" /> </head> <body> <div align="center"> <div id="body"> <p> </p> <div id="header"> <div id="navicons"><img src="images/contact.png" alt="Contact Us"/><img src="images/login.png" alt="Register/Login" /><img src="images/cart.png" alt="View your Cart" /></div> </div><!--header --> <div id="leftnav"> <ul> <li></li> <li></li> <li><b>By category</b></li> <?php include('includes/connector.php'); $result = mysql_query('SELECT * FROM `tbl_category`', $dbConn) or die(mysql_error()); if(mysql_num_rows($result) < 1) { echo('Sorry, no results were found.'); } else { while($row = mysql_fetch_array($result)) { echo ('<li><a href="productlist.php?cat_id='.$row[cat_id].'">'.$row[cat_name].'</a></li>'); } } ?> <li><b>By Manufacturer</b></li> <?php include('includes/connector.php'); $result = mysql_query('SELECT * FROM `tbl_makes`', $dbConn) or die(mysql_error()); if(mysql_num_rows($result) < 1) { echo('Sorry, no results were found.'); } else { while($row = mysql_fetch_array($result)) { echo ('<li><a href="makes.php?cat_id='.$row[make_id].'">'.$row[make].'</a></li>'); } } ?> </ul> </div> <div id="content"> <h2>Login to Your Account</h2> <form name="login" method="post" action="login.php" onsubmit="return checkform()"> <table> <?php if (isset($message)) { echo "<tr><td style='color: red' colspan='2' align='center'>$message <br /></td></tr>"; } ?> <tr><td> Email Address:</td><td><input name="email" type="text" size="30" /></td></tr> <tr><td>Password:</td><td><input name="password" type="password" size="30" /></td></tr> <tr><td><input type="hidden" name="submit" id="hiddenField" value="1"/> <input name="login" type="submit" value="Login" class="button" /></td> <td>Need to register click <a href="register.php">here</a></td> </tr> </table> </form> </div> <div id="bottom-nav"><a href="contact.php">Contact</a> | <a href="account/index.php">My Account</a> | Testimonials | Privacy |</div> <div id="credit">design by <a href="http://www.bravo14.co.uk" target="_blank">bravo14</a></div> <div id="copyright">© Quantum Phones</div> </div> </div> </body> </html> //line 153
  5. I have downloaded plaincart, but want to force the customers to register and login before going to the checkout. Has anybody attempted and succeeded with this, and how did you do it? Any support would be appreciated
  6. Hello guys I have put together a music player in flash that reads a XML file, but what I want to do is allow the user to upload their own tracks and the Music player picks up the details. Does anybody have any ideas? Kind regards Mark
  7. Hi guys I am probably missing something completely obvious, but what I am trying to do is everytime an entry gets added to a database an email is sent out. <?php // Connect to the database $cnx = mysql_connect('ip, 'user', 'pwd') OR die("Unable to connect to database!"); mysql_select_db('db', $cnx); if ($_POST['submit_form'] == 1) { // Set Variables $data = mysql_real_escape_string(trim($_POST['fcktext'])); $topic = ($_POST['topic']); $title = ($_POST['title']); $mileage = $_POST['mileage']; $intro = substr ($data,0,100); $subject = "A new Post has been added to marksmarathonmadness.co.uk"; $adminmail="update@marksmarathonmadness.co.uk"; //Send Email Update $getlist='SELECT * FROM `email_table` WHERE `validated` = \'1\''; //select validated e-mails $getlist2=mysql_query($getlist) or die("Could not get list"); while($getlist3=mysql_fetch_array($getlist2)) { $headers = "From: $adminmail \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; //send HTML enabled mail $headers .= "MIME-Version: 1.0 "; mail("$getlist3[email]","$subject","Hi, There has been a new post added to www.marksmarathonmadness.co.uk",$headers); } // Save to the database $res = mysql_query("INSERT INTO posts (topic_id, post, title,intro,distance) VALUES('$topic','$data','$title','$intro','$mileage')"); $post = mysql_query("UPDATE `topics` SET `posts` = posts+'1' WHERE `topic_id` ='".$topic."'"); if (!$res) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: index.php"); } ?> The entry gets added to the database, but the email doesn't get sent. Any ideas Many thanks Mark
  8. I have downloaded plaincart, but want to force the customers to register and login before going to the checkout. Has anybody attempted and succeeded with this, and how did you do it?
  9. Cheers Guys as ever the phonts of all knowledge, one last thing is this bit correct to be able to display the user details ? <?php session_start(); if($_SESSION['auth'] !="yes") { header ("Location:login_reg.php"); } else { echo"<html><head><title>Your Account</title></head><body>"; echo"<h2>Welcome back "$_SESSION['email']."</h2></body></html>"; } ?> For now I just want to display the email from the previous page.
  10. Thanks for your reply, do I start it after I set the variable or before?
  11. Hi all I am starting to work with sessions (first attempt), the user signs in using a the following code $email=$_POST["email"]; $password=$_POST["password"]; //select database mysql_select_db('phonestore', $con); $query = "SELECT * FROM customers WHERE email = '".$email."'"; $result=(mysql_query($query,$con)); if (!mysql_query($query,$con)){ die('Error: ' . mysql_error()); } else { // count the number of rows $no_of_results = mysql_num_rows($result); } // logic test - if there is 1 or more row in the query result output an message that the email address already exists if(mysql_num_rows($result) > 0) { $sql="SELECT * FROM customers WHERE email ='$email' and password=md5('$password')"; $result2=(mysql_query($query,$con)); if (!mysql_query($query,$con)){ die('Error: ' . mysql_error()); } else { echo // count the number of rows $no_of_results2 = mysql_num_rows($result2); $_SESSION['auth']="yes"; $_SESSION['logname']=$email; header("Location: account.php"); } } mysql_close($con); ?> and then go to page account.php in the following code <?php session_start(); if($_SESSION['auth'] !="yes") { header ("Location:login_reg.php"); } else { echo"<html><head><title>Your Account</title></head><body>"; echo"<h2>Welcome back" .$_SESSION['name']."</h2></body></html>"; } ?> The problem I have is that even after I log on it takes me back to the login page Any ideas or advice would be much appreciated
  12. Thanks for that, have made the correction but now I am getting the die error and again can't see anything wrong with the query or execution of it $cxn = mysql_connect($host, $user, $passwd, $dbname) or die ("Couldn't connect to server"); $sql = "SELECT username FROM customers WHERE username = '$username'"; $result = mysql_query($cxn,$sql) or die ("Query died: user name"); //line 145
  13. Hi guys I have included a part of the code I am trying to use, I am basically trying to see if a username is already in use before adding the record to the database. <?php include ("includes/connector.php"); //*assign names to variables $username = $_POST[username]; $first_name = $_POST[firstname]; $surname = $_POST[surname]; $email = $_POST[email]; $password = $_POST[password]; $address1 = $_POST[address1]; $address2 = $_POST[address2]; $address3 = $_POST[address3]; $address4 = $_POST[address4]; $postcode = $_POST[postcode]; //*check if username already exists $cxn = mysql_connect($host, $user, $passwd, $dbname) or die ("Couldn't connect to server"); $sql = "SELECT username FROM customers WHERE username = '$username'"; $result = mysql_query($cxn,$sql) or die ("Query died: user name"); //line 145 $num = mysql_num_rows($result); The error message I am getting is Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\alhassam\register.php on line 145, I have indicated line 145 above, can anyone point out my error. Cheers
  14. Hi all I have written a piece of code that will send a newsletter to a set of email addresses in a table I also wanted to insert the newsletter into a separate table <?php include "connect.php"; if(isset($_POST['submit'])) { $subject=$_POST['subject']; $nletter=$_POST['nletter']; if(strlen($subject)<1) { print "You did not enter a subject."; } else if(strlen($nletter)<1) { print "You did not enter a message."; } else { $nletter=$_POST['nletter']; $subject=$_POST['subject']; $nletter=stripslashes($nletter); $subject=stripslashes($subject); $lists=$_POST['lists']; $nletter=str_replace("rn","<br>",$nletter); $adminmail="news@yardleyheroes.co.uk"; $path="http://www.yardleyheroes.co.uk/newsletter"; //the block above formats the letter so it will send correctly. $getlist='SELECT * FROM `email_table` WHERE `validated` = \'1\''; //select validated e-mails $getlist2=mysql_query($getlist) or die("Could not get list"); while($getlist3=mysql_fetch_array($getlist2)) { $headers = "From: $adminmail \r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1 "; //send HTML enabled mail $headers .= "MIME-Version: 1.0 "; mail("$getlist3[email]","$subject","$nletter",$headers); } print "Newsletter Sent."; } } else { print "<form action='sendletter.php' method='post'>"; print "Subject:<br>"; print "<input type='text' name='subject' size='20' class='textbox'><br>"; print "Message:<br>"; include_once "includes/fckeditor/fckeditor.php"; $oFCKeditor = new FCKeditor('nletter'); $oFCKeditor->BasePath = "includes/fckeditor/"; $oFCKeditor->Value = ""; $oFCKeditor->Width = 540; $oFCKeditor->Height = 400; echo $oFCKeditor->CreateHtml(); print "<br><input type='submit' name='submit' value='submit' class='textbox'></form>"; } ?> The newsletter is sent ok, but the data is not added to the table, can anyone point out what I have done wrong? Cheers
  15. Cheers Guys That has worked
  16. I have installed FCKEditor on a website I have put together, I have been able to insert a post into MySQL from the editor, but I can't seem to get the post to update, I have used the code below <?php // Connect to the database $cnx = mysql_connect('IP', 'user', 'password') OR die("Unable to connect to database!"); mysql_select_db('dbname', $cnx); if ($_POST['submit_form'] == 1) { // Save to the database $data = mysql_real_escape_string(trim($_POST['fcktext'])); $post_id = ($_POST['post_id']); $intro = substr ($data,0,100); $res = mysql_query("UPDATE `posts` SET post = '".$data."' WHERE post_id =".$post_id.""); if (!$res) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: index.php"); } include_once "includes/fckeditor/fckeditor.php"; ?> <!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"><!-- InstanceBegin template="/Templates/gavsteradmin.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Gavster Says | MC Gavster The Lyrical Gangsta</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <link href="../style/gavster.css" rel="stylesheet" type="text/css" /> </head> <body> <div align="center"> <div style="width:850px; border:2px solid #0066FF; background-color:#3366FF"> <div id="header"> <div id="head"></div> </div> <div id="topics"> <h2>Admin</h2> <ul style="list-style:none; text-align:left"><li><a href="add_post.php">Add a post</a></li> <li><a href="add_topic.php">Add a Topic</a></li> </ul> <div align="left"> </div> </div> <div id="maintext"><!-- InstanceBeginEditable name="maintext" --> <form action="edit_post.php" method="post"> <?php // Get data from the database $query = mysql_query('SELECT * FROM `posts`where `post_id`=\'' . $_GET['post_id'] . '\''); $row = mysql_fetch_array($query); //other fields within post echo ('<input name="title" type="text" value="'.$row[title].'" width="50" readonly="true"/>'); echo('<input name="post_id" type="hidden" value="'.$row[post_id].'"/>'); // Configure and output editor $oFCKeditor = new FCKeditor('fcktext'); $oFCKeditor->BasePath = "includes/fckeditor/"; $oFCKeditor->Value = $row["post"]; $oFCKeditor->Width = 540; $oFCKeditor->Height = 400; echo $oFCKeditor->CreateHtml(); ?> <br /> <input type="hidden" name="submit_form" value="1" /> <input type="submit" value="Save Post" class="button"/> </form> <!-- InstanceEndEditable --></div> <div id="credit">design by <a href="http://www.bravo14.co.uk" target="_blank">bravo14</a></div> <div id="copyright">© Gavin Netherton</div> </div> </div> </body> <!-- InstanceEnd --></html> <?php // Close the database connection mysql_close($cnx); ?> I don't get an error message, but the entry in the database doesn't update. Any help would be appreciated
  17. Hello I have ot part of it cracked, but am now getting an error message of Parse error: syntax error, unexpected '[' in /home/fhlinux144/g/gavstersays.co.uk/user/htdocs/admin/edit_post.php on line 12 The entire code page is <?php // Connect to the database $cnx = mysql_connect('IP', 'user', 'pword') OR die("Unable to connect to database!"); mysql_select_db('d_base', $cnx); if ($_POST['submit_form'] == 1) { // Save to the database $data = mysql_real_escape_string(trim($_POST['fcktext'])); $topic = ($_POST['topic']); $title = ($_POST['title']); $intro = substr ($data,0,100); $res = mysql_query("INSERT INTO posts (topic_id, post, title,intro) VALUES('$topic','$data','$title','$intro')"); if (!$res) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: index.php"); } include_once "includes/fckeditor/fckeditor.php"; ?> <!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"><!-- InstanceBegin template="/Templates/gavsteradmin.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Gavster Says | MC Gavster The Lyrical Gangsta</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <link href="../style/gavster.css" rel="stylesheet" type="text/css" /> </head> <body> <div align="center"> <div style="width:850px; border:2px solid #0066FF; background-color:#3366FF"> <div id="header"> <div id="head"></div> </div> <div id="topics"> <h2>Admin</h2> <ul style="list-style:none; text-align:left"><li><a href="add_post.php">Add a post</a></li> <li><a href="add_topic.php">Add a Topic</a></li> </ul> <div align="left"> </div> </div> <div id="maintext"><!-- InstanceBeginEditable name="maintext" --> <form action="add_post.php" method="post"> <table> <?php echo ('<tr><td><select name="topic" class="button">'); $con = mysql_connect('host', 'user', 'pword', true); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('dbname', $con); $result = mysql_query('SELECT * FROM `topics`', $con) or die(mysql_error()); if(mysql_num_rows($result) < 1) echo('<option>there is no data in table..</option>'); else { while($row=mysql_fetch_assoc($result)) { echo('<option value='.$row[topic_id].'>'.$row[topic].'</option>'); } } echo ('</select></td></tr>'); ?> <tr><td><input name="title" type="text" value="Enter Title of Post Here..." size="70" class="button"/></td></tr> <?php echo ('<tr><td>'); $oFCKeditor = new FCKeditor('fcktext'); $oFCKeditor->BasePath = "includes/fckeditor/"; $oFCKeditor->Value = ""; $oFCKeditor->Width = 540; $oFCKeditor->Height = 400; echo $oFCKeditor->CreateHtml(); echo ('</td></tr>'); ?> <br /> <tr><td><input type="hidden" name="submit_form" value="1" /> </td></tr> <tr><td><input type="submit" value="Save Post" class="button"/> </td></tr> </table> </form> <!-- InstanceEndEditable --></div> <div id="credit">design by <a href="http://www.bravo14.co.uk" target="_blank">bravo14</a></div> <div id="copyright">© Gavin Netherton</div> </div> </div> </body> <!-- InstanceEnd --></html> <?php // Close the database connection mysql_close($cnx); ?>
  18. Hello all I have installed FCKEditor onto a site I have put together but am struggling to get the post to update if they want to make any changes I have the following code if ($_POST['submit_form'] == 1) { // Save to the database $data = mysql_real_escape_string(trim($_POST['fcktext'])); $post_id = ($_POST['post_id']); $intro = substr ($data,0,100); $res = mysql_query("UPDATE `posts` SET post = '".$data."' WHERE post_id ='".$post_id."'"); if (!$res) die("Error saving the record! Mysql said: ".mysql_error()); // Redirect to self to get rid of the POST header("Location: index.php"); } include_once "includes/fckeditor/fckeditor.php"; ?> Can anyone spot any errors in the code? Cheers Mark [/code
  19. Cheers Guys You never fail to assist
  20. Hello all I have the following error on a page Parse error: syntax error, unexpected $end in /home/fhlinux171/b/bravo14.co.uk/user/htdocs/gavster/article.php on line 107 <?php $con = mysql_connect('213.171.219.92', 'gav', 'gavin', true); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('gavstersays', $con); $result = mysql_query('SELECT * FROM `comments` where `post_id`=\'' . $_GET['post_id'] . '\'' , $con) or die(mysql_error()); if(mysql_num_rows($result) < 1) { echo('<tr><td>Sorry, no results were found.</td></tr>'); } else { while($row = mysql_fetch_array($result)) { echo ('<div class="comment">'); echo('<p>'.$row[name].' | '.$row[commentdate].'</p>'); echo('<p>'.$row[comment].'</p>'); echo('</div>'); mysql_close($con); ?> Line 107 is </html> I can't spit anything wrong with the code, but have probably gone code blind. Any ideas
  21. Hi All Using the code below I am getting an error of Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fhlinux171/b/bravo14.co.uk/user/htdocs/gavster/headlines.php on line 41, however I have copied a page that works and changed the relevant parts which will mean that line 41 is OK, I appreciate that the code could probably be slicker, however still learning php, can anyone spot any errors with the code that would get the error ? <?php $con = mysql_connect('ip', 'user', 'password', true); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db('gavstersays', $con); $result = mysql_query('SELECT * FROM `posts`where `topic_id`=\'' . $_GET['topic_id'] . '\'' , $con) or die(mysql_error()); if(mysql_num_rows($result) < 1) { echo('<tr><td colspan="2">Sorry, no results were found.</td></tr>'); } else { while($row = mysql_fetch_array($result)) { echo('<tr><td>'.date("d-M-Y", strtotime($row[postdate])).'</td>'); echo('<td><a href="article.php?post_id='.$row[post_id].'">'.$row[title].'</a></td></tr>'); } } ?>
  22. Sorry guys should have said the field is a date field not datetime does that make any difference to what I am trying to achieve?
  23. Hi all The date format in the mysql database is yyyy-mm-dd and I want to display the date dd-mmm-yyyy I have tried using the following code after having a look at other sites echo ('<tr><td>'.$row[Date].(j-M-Y)'</td><td><b>Yardley</b></td>'); and I am getting the following error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fhlinux147/y/yardleyheroes.co.uk/user/htdocs/fixtures.php on line 59 Can anyone give me any pointers
  24. Just cracked it, sorry if I have wasted anybody's time, still learning
  25. Hi If you have a look at www.yardleyheroes.co.uk/fixtures.php you will see a list of fixtures, however the results are empty in the database, but they show as a zero $result = mysql_query('SELECT * FROM `fixtures` ORDER BY `date`', $con) or die(mysql_error()); if(mysql_num_rows($result) < 1) { echo('<tr class="profiletext"><td colspan="7">Sorry, no results were found.</td></tr>'); } else { while($row = mysql_fetch_array($result)) { if ($row[HomeAway]=="Home") { echo ('<tr><td>'.$row[Date].'</td><td><b>Yardley</b></td>'); echo ('<td align="center">'.$row[yardley_goals].'-'.$row[opposition_goals].'</td><td>'.$row[Opposition].'</td>'); echo ('<td></td><td></td><td><a href="http://www.yardleyheroes.co.uk/matchfines.php?match_id='.$row[match_id].'">View Fines</a></td></tr>'); } else{ echo ('<tr><td>'.$row[Date].'</td><td>'.$row[Opposition].'</td>'); echo ('<td align="center">'.$row[opposition_goals].'-'.$row[yardley_goals].'</td><td><b>Yardley</b></td>'); echo ('<td></td><td></td><td><a href="http://www.yardleyheroes.co.uk/matchfines.php?'.$row[match_id].'">View Fines<a></td></tr>'); } } } mysql_close($con); ?> How do I show a blank field if the value sin the database are blank?
×
×
  • 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.