Jump to content

NealeWeb

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

NealeWeb's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi guys and wow, thanks for all the replies but while i was away waiting i was just playing with the code, changing things to see if i could get it to work and i found that it actually isnt the query thats the problem its something else i have on the page. I have a small page transition script that i found on the internet and when i removed it, it all worked fine. So now i just need to figure out why it is affecting my page as it only happens when i try to submit a form. Here is the script: <script type="text/javascript"> (function inittrans() { var params = //All params are optional, you can just assign {} { "navB" : "slide reverse", //Effect for navigation button, leave it empty to disable it "but" : true, //Flag to enable transitions on button, false by default "cBa" : onTransitionFinished // function() { alert("Done!"); } //callback function }; new ft(params); })(); function onTransitionFinished() { //Do anything you want } </script> And in all my links i have, data-ftrans="slide" after the href. I got the script from here: http://www.fasw.ws/faswwp/non-jquery-page-transitions-lightweight/ Any ideas?
  2. Hi guys i am trying to search results from a database using SELECT * FROM table_name WHERE event LIKE '%" . $search . "%' OR date LIKE '%" . $search . "%' This works fine in Firefox and in IE, but when i try it in safari, it seems to pull up the right results but then straight away changes and gives me all the results from the table. I am sure it has soomething to do with the LIKE operator because when i tried SELECT * FROM table_name WHERE date = (the date i was trying to search for) It worked fine. So the only difference was i just manually told it what to look for. And it worked
  3. the connecct info is definatley ok as sometimes it works fine
  4. The code below is in a php file thats included (<?php include(messages.php); ?>) in a div thats refreshed every 5 mins using javascript. <?php $dbHost = "localhost"; $dbUser = "#####"; $dbPass = "#####"; $dbname = "#####"; $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); mysql_query("UPDATE members SET active=NOW() WHERE member_id = '$_SESSION[sESS_MEMBER_ID]'"); $requete = "SELECT * FROM public_messages ORDER BY id desc"; $result = mysql_query ($requete,$db); while($row = mysql_fetch_array($result)) { $msg = str_replace ("\r\n", '<br />', $row['message']); $msg = str_ireplace($badwords,'<span class="censored">[Censored]</span>',$msg); $author = $row['author']; $dateandtime = $row['date_time']; $mid = $row['msg_id']; $aid = $row['auth_id']; $cmnts = $row['comments']; echo "<div class=\"msg_box\"><!--Start msg_box --> <img class=\"avatar\" src=\"users/$author/avatar.jpg\" /> <span class=\"msgblue\">$author</span><br /> <span class=\"msgdark\">$msg</span> <div class=\"msg_footer\"> <div class=\"footer_left\"> <span class=\"posted\">Posted: </span><span class=\"posted_date_time\">$dateandtime</span> </div> <div class=\"footer_right\"> <a href=\"messagecomments.php?msgid=$mid\"><span class=\"msg_options\">Comments ($cmnts)</span></a> <img class=\"bubble\" src=\"images/speechbubble.png\" />"; if ($_SESSION['SESS_MEMBER_ID'] == $aid) { echo "<a href=\"edit_message.php?msgid=$mid\" onclick=\"return confirm('You are about to edit this message.');\"><img class=\"edit\" src=\"images/edithover.png\" /></a><a href=\"deletemessage.php?msgid=$mid\" onclick=\"return confirm('You are about to delete this message.');\"> <img class=\"delete\" src=\"images/deletehover.png\" /></a>"; } else { echo "<a href=\"reportmessage.php?msgid=$mid&activeuser=$activeuser\" onclick=\"return confirm('You are about to anonymously report this message as unsuitable.');\"><img class=\"report\" src=\"images/report.png\" /></a>"; } echo " </div> </div></div><!--End msg_box -->"; } mysql_close($db); ?>
  5. Im making a site for my family to leave messages for everyone to see but every now and then the message wont load and i get theses errors, Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home/#####/public_html/#####.com/messages.php on line 17 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/#####/public_html/#####.com/messages.php on line 18 Warning: mysql_query() [function.mysql-query]: Access denied for user '#####'@'localhost' (using password: NO) in /home/#####/public_html/#####.com/messages.php on line 21 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/#####/public_html/#####.com/messages.php on line 21 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/#####/public_html/#####.com/messages.php on line 24 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/#####/public_html/#####.com/messages.php on line 25 Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/#####/public_html/#####.com/messages.php on line 54 i also recieved this error once Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) The hosting support team have been no help at all.
  6. I have no idea what im doing wrong but this just isnt working, theres no error messages but im not getting any of the emails. Here is all the code that i had anything to do with editing, i have removed any personal info from it. <?php $dbhost = 'localhost'; $dbuser = ' '; $dbpass = ' '; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db(" ", $conn); $result = mysql_query("SELECT ****, ********** FROM **** WHERE name='*****'"); while($row = mysql_fetch_array($result)) { $message = "<p><u><b><font size=\"5\" color=\"#800080\">********************</font></b></u></p> <p><b><font color=\"#800080\" size=\"4\">**************************************************</font></b></p> <p><b><font color=\"#800080\">*********</font></b> <b><font color=\"#333333\">**********</font></b></p> <p><b><font color=\"#800080\">********</font></b> <font color=\"#333333\"><b>***********</b></font></p> <p><font color=\"#800080\"><b>*******</b></font> <font color=\"#333333\"><a href=\"***********************************************</a></font></p> <p> </p>"; } $query=mysql_query('SELECT `email`,`name` FROM `users`'); //grab emails and names from database while($row = mysql_fetch_array($query)) //start a loop to send an email to each individual { //mail function with $row['email'] as the email address //I'm using phpmailer as an example here - - > include_once('phpMailer/class.phpmailer.php'); $mail = new PHPMailer(); // defaults to using php "mail()" $body = $message; //message inside the email $mail->From = "**************"; //email address that the email is being sent from $mail->FromName = "*************"; //more in depth for who the mail is from. $mail->Subject = "***********************************"; //The subject for the message //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->AddAddress($row[email], $row['name']); } mysql_close($conn); ?>
  7. Ok sorry onne more thing i am trying to use this in an existing echo but im having trouble. I get this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 48 This is what i have tried: echo '<div align="center"> <table border="0" cellpadding="10" cellspacing="0" width="969" background="imgs/reviewbox.png" height="157"> <tr> <td height="19" ><span class="font1">' . $jtitle . '</span></td> <td height="19" > <p align="right"><a href="review.php?review_id=' . $revid . '"><span class="font">View Full review</span></a></td> </tr> <tr> Line 48 >>> <td valign="top" colspan="2"><span class="font">substr($t,0,, (strlen($t) > ? ' <a href="yourlink">Read more...</a>' : '';</span></td> <<< Line 48 </tr> </table> </div>'; Is it possible to make it a variable like this in any way: <?php $t = "Your text"; $y= substr($t,0,, (strlen($t) > ? ' <a href="yourlink">Read more...</a>' : ''; echo $y; ?> I am very new at php so im sure im making some pretty silly mistakes.
  8. Wow that is perfect it works great thankyou so much
  9. I am wanting to display large text blocks from a database but i would like to stop the text if its longer than 600 characters and display Read more... as a link. Can someone please help me?
  10. Ok great no error anymore thankyou but im now getting a blank page with no results. Any idea what i did wrong?
  11. Thankyou for the help but i am now getting this error Parse error: syntax error, unexpected $end in /members.php on line 31 members.php <?php session_start(); require 'database.php'; $nuser=$_SESSION['user']; $auser=$_SESSION['admin']; if($nuser){ $userfinal=$nuser; }elseif($auser){ $userfinal=$auser; } if(isset($userfinal)){ $Members = mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error()); ?> <table border="0"> <?php while($name = mysql_fetch_assoc($Members)) { ?> <tr> <?php echo "<td><a href=\"member_profile.php?user=" . $name['user'] . "\">" . $name['user'] . "</a></td>"; ?> </tr> <?php } ?> </table> <<<<<<<<<< Line 31
  12. I am following a tutorial and have come across an error, i have checked that i made no mistakes when copying and have tried everything i know to try but im not that experienced so ive had no luck. Could someone pls point out the mistake for me. Parse error: syntax error, unexpected $end in /members.php on line 30 members.php <?php session_start(); require 'database.php'; $nuser=$_SESSION['user']; $auser=$_SESSION['admin']; if($nuser){ $userfinal=$nuser; }elseif($auser){ $userfinal=$auser; } if(isset($userfinal)){ $Members = mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <table border="0"> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <tr> <?php echo '<td><a href="member_profile.php?username=' . $name['user'] . '">' . $name['user'] . '</a></td>'; ?> </tr> <?php <<<<<<<<<< Line 30 } ?> </table>
  13. Ok this time i managed to get it to display the results correctly but now i can only get the first page, when i go to next page it says not found. Here is the code and the link: http://www.nealeweb.com/steven2/ <?php $rpp = 24; // results per page $adjacents = 4; $page = intval($_GET["page"]); if($page<=0) $page = 1; $reload = $_SERVER['PHP_SELF']; $dbhost = "localhost"; $dbuser = ""; $dbpass = ""; $dbname = ""; // connect to your DB: $link_id = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname, $link_id); // select appropriate results from DB: $sql = "SELECT * FROM tracks ORDER BY cat_id asc"; $result = mysql_query($sql, $link_id); // count total number of appropriate listings: $tcount = mysql_num_rows($result); // count number of pages: $tpages = ($tcount) ? ceil($tcount/$rpp) : 3; // total pages, last page number $count = 0; $i = ($page-1)*$rpp; while(($count<$rpp) && ($i<$tcount)) { mysql_data_seek($result,$i); $row = mysql_fetch_array($result); $catno = $row['cat_id']; $songname = $row['song']; $artistname = $row['artist']; $ryear = $row["year"]; // output each row: echo'<tr> <td valign="top" width="112" height="27"><span class="font">'.$catno.'</span></td> <td valign="top" width="536" height="27"><span class="font">'.$songname.'</span></td> <td valign="top"><span class="font" height="27">'.$artistname.'</span></td> <td valign="top" width="80" height="27"><span class="font">'.$ryear.'</span></td> </tr>'; $i++; $count++; } include("pagination3.php"); echo paginate_three($reload, $page, $tpages, $adjacents); ?>
  14. I am building my uncle an online music catalogue and am trying to use pagination http://www.phpeasycode.com/pagination/ but for some reason it is only showing the cat_id data from the databse and even then its only the last entry. I need it to show all cat_id, song, artist and year from the database and not just the same ones over and over again. Here is a link to the page so you can see whats happening: http://www.nealeweb.com/steven2/ And here is the code, Can anybody tell me where i have gone wrong please. $rpp = 24; // results per page $adjacents = 4; $page = intval($_GET["page"]); if($page<=0) $page = 1; $reload = $_SERVER['PHP_SELF']; // connect to your DB: $dbHost = ""; $dbUser = ""; $dbPass = ""; $dbname = ""; $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); // select appropriate results from DB: $requete = "SELECT cat_id, song, artist, year FROM tracks ORDER BY cat_id asc"; $result = mysql_query ($requete,$db); // count total number of appropriate listings: $tcount = mysql_num_rows($result); // count number of pages: $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number $count = 0; $i = ($page-1)*$rpp; while(($count<$rpp) && ($i<$tcount)) { mysql_data_seek($result,$i); $query = mysql_fetch_array($result); // output each row: echo'<tr> <td valign="top" width="112" height="27"><span class="font">'.$catno.'</span></td> <td valign="top" width="536" height="27"><span class="font">'.$songname.'</span></td> <td valign="top"><span class="font" height="27">'.$artistname.'</span></td> <td valign="top" width="80" height="27"><span class="font">'.$ryear.'</span></td> </tr>'; $i++; $count++; } // call pagination function: include("paginate.php"); echo paginate_three($reload, $page, $tpages, $adjacents);
  15. I have a guestbook and i want to record and display the time of each post but at the moment all the times are added to the database including seconds so it looks like this - 05:42:33, i just want the hours and minutes like this - 05:42. This is the code that adds the time. $time = date("HH:MM"); $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); $sql="INSERT INTO guestbook (`time`) VALUES ( And this is the code that displays it <?php $db = mysql_connect($dbHost,$dbUser,$dbPass); mysql_select_db($dbname,$db); $requete = " time FROM guestbook ORDER BY ID desc LIMIT 1"; $result = mysql_query ($requete,$db); while($row = mysql_fetch_assoc($result)) { $time = $row["time"]; echo '<span class="font2">'.''.$time.''.'</span>'; } ?> Can anybody help me.
×
×
  • 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.