Jump to content

doofy

Members
  • Posts

    40
  • Joined

  • Last visited

  • Days Won

    1

doofy last won the day on August 23 2013

doofy had the most liked content!

Profile Information

  • Gender
    Not Telling

doofy's Achievements

Member

Member (2/5)

4

Reputation

  1. Took your advice, looked into using preg_replace solely. $search = '#(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})#x'; $replace = '<center><iframe width="560" height="315" src="http://www.youtube.com/embed/\\1" frameborder="0" allowfullscreen></iframe></center>'; $embed = preg_replace($search, $replace, $embed ); Figured I'd post the above in case any other noobs came by with a similar misunderstanding of how to get it working properly. Cheers!
  2. Ok, that's what I figured might be the case, but when I tried doing preg_match_all(), I must not have done it correctly with a loop to return the arrays from it. Instead of moving to the next line of text (or potential psuedo code) it would simply return all values of the youtube instances immediately within the function, so it wouldn't be in the order he typed it in. I'll see what I can come up with with preg_replace itself as suggested after I do more research. Thank you for your time thus far.
  3. Hello, I'm new to preg_match & preg_match functions. I'm trying to get my brother to post link within a [pseudo BB code tag], which would then embed itself. I don't want him being able to copy and paste codes blindly. Here is the current regex: function BlogCode($blogcode) { if( !strstr($blogcode, '[') ) { return $blogcode; } // Soundcloud if (preg_match('%(?:soundcloud.com)/(?:tracks/)([0-9]+)%i', $blogcode, $match)) { $track_id = $match[1]; $blogcode = preg_replace("~\\[video]([^\\[]*)\\[/video\\]~i","<br /><center><iframe width='100%' height='166' scrolling='no' frameborder='no' src='https://w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/$track_id'></iframe></center><br /><br />",$blogcode); } // Youtube if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $blogcode, $match)) { $video_id = $match[1]; $blogcode = preg_replace("~\\[video]([^\\[]*)\\[/video\\]~i","<br /><center><object width='640' height='390'><param name='movie' value='https://www.youtube.com/v/".$video_id."?version=3&autoplay=0'></param><param name='allowScriptAccess' value='always'></param><embed src='https://www.youtube.com/v/".$video_id."?version=3&autoplay=0' type='application/x-shockwave-flash' allowscriptaccess='always' width='640' height='390'></embed></object></center>",$blogcode); } return $blogcode; } My issue is when he is using multiple tags, as it will only initialize the $video_id variable the first time around, as it displays the same video instead of individual youtubeID's What am I doing wrong here? I'm sure it's something goofy, but this is my first time trying to do something like this. Thanks in advance.
  4. Thanks for the help guys, you got me in the right direction.
  5. Sorry, it was late last night. I meant it expands my container. Before without the menu.css it was 990px wide, now nothing is adhering to the container. Here is a screen shot when zoomed out (Before it worked fine, now with the nav bar it's all screwy, but I can't figure out how to fix the css):
  6. Sorry about that guys.. Thank you very much for the quick replies though, already I feel like I'll get through this issue. <div id="container"> <ul id="menu"> <li><a href="main.php">Home</a></li> <li class="menu_right"><a href="profile.php" class="drop">My Check List</a> <div class="dropdown_1column align_right"> <div class="col_1"> <ul class="simple"> <li><a href="add-goal.php">Add a Goal</a></li> <li><a href="profile.php">My Profile</a></li> <li><a href="edit-profile.php">Edit Profile</a></li> <li><a href="settings.php">Account Settings</a></li> </ul> </div> </div> </li> <li class="menu_right"><a href="activity.php">Member Activity</a></li> <li class="menu_right"><a href="about.php" class="drop">About</a> <div class="dropdown_1column align_right"> <div class="col_1"> <ul class="simple"> <li><a href="about.php">About Us</a></li> <li><a href="contact.php">Contact Us</a></li> <li><a href="faq.php">FAQ</a></li> <li><a href="terms.php">Terms & Conditions</a></li> <li><a href="privacy.php">Privacy Statement</a></li> </ul> </div> </div> </li> </ul> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td><div id="contentbox">content</div></td> <td><div id="contentbox">content</div></td> </tr> </table> </div>
  7. The organized inline list is extending past my container. I've gotten this far to trouble shoot it, but have no clue how to fix this css. Any direction would be appreciated, I thought it was a padding issue from everything I've read, but I couldn't figure out how to fix this. Thank you in advance for helping a css n00b. ul, li { font-size:12px; font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; line-height:21px; text-align:left; } #container{ margin:0 auto; width:990px; } #menu { z-index:1; list-style:none; width:940px; margin:30px auto 0px auto; height:43px; padding:0px 20px 0px 20px; /* Rounded Corners */ -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; background: #000000; /* Borders */ border: 2px solid #3a3a3a; -moz-box-shadow:inset 3px 3px 4px #000000; -webkit-box-shadow:inset 3px 3px 4px #000000; box-shadow:inset 3px 3px 4px #000000; } #menu li { float:left; display:block; text-align:center; position:relative; padding: 4px 10px 4px 10px; margin-right:30px; margin-top:7px; border:none; } #menu li:hover { border: 1px solid #3a3a3a; padding: 4px 9px 4px 9px; background: #000000; /* Rounded corners */ -moz-border-radius: 5px 5px 0px 0px; -webkit-border-radius: 5px 5px 0px 0px; border-radius: 5px 5px 0px 0px; } #menu li a { font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; font-size:12px; color: #bb7f2a; display:block; outline:0; text-decoration:none; } #menu li:hover a { color:#bb7f2a; text-decoration:underline; } #menu li .drop { padding-right:21px; background:url("../images/drop.png") no-repeat right 8px; } #menu li:hover .drop { background:url("../images/drop.png") no-repeat right 7px; } .dropdown_1column { margin:4px auto; float:left; position:absolute; left:-999em; /* Hides the drop down */ text-align:left; padding:10px 5px 10px 5px; border:1px solid #3a3a3a; border-top:none; /* Gradient background */ background:#000000; /* Rounded Corners */ -moz-border-radius: 0px 5px 5px 5px; -webkit-border-radius: 0px 5px 5px 5px; border-radius: 0px 5px 5px 5px; } .dropdown_1column { width: 140px; } #menu li:hover .dropdown_1column { left:-1px; top:auto; } .col_1 { width:130px; display:inline; float: left; position: relative; margin-left: 5px; margin-right: 5px; } #menu .menu_right { float:left; } #menu li .align_right { /* Rounded Corners */ -moz-border-radius: 5px 0px 5px 5px; -webkit-border-radius: 5px 0px 5px 5px; border-radius: 5px 0px 5px 5px; } #menu li:hover .align_right { left:auto; right:-1px; top:auto; } #menu p, #menu h2, #menu h3, #menu ul li { font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; line-height:21px; font-size:12px; text-align:left; } #menu li:hover div a { font-size:12px; color:#FFF; } #menu li:hover div a:hover { color:#029feb; } .strong { font-weight:bold; } .italic { font-style:italic; } #menu li ul { list-style:none; padding:0; margin:0 0 12px 0; } #menu li ul li { font-size:12px; line-height:24px; position:relative; padding:0; margin:0; float:none; text-align:left; width:130px; } #menu li ul li:hover { background:none; border:none; padding:0; margin:0; } #searchcontainer { position:relative; } #search { position:absolute; top:-35px; right:35px; }
  8. Well I figured out what was wrong for one part as to why it wasn't populating the ID or username and now I get a new error: "Insert Error: Unknown column 'goal1' in 'field list'" <? error_reporting(ALL); session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header ("Location: index.php"); } $username = $_SESSION['username']; require("connect.php"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $result = mysql_query(" SELECT * from login WHERE username = '$username' ") or die(mysql_error()); $row = mysql_fetch_array($result); $ID = $row['ID']; $NumGoals = $row['NumGoals']; $NumGoals++; $newgoal = mysql_real_escape_string(htmlspecialchars($_POST['newgoal'])); $newgoalid = "goal"; $newgoalid .= $NumGoals; $newgoaldate = mysql_real_escape_string(htmlspecialchars($_POST['goaldate'])); // Verify if last column name already exists in table $fields = mysql_list_fields('doofyd5_checkbucket', 'goals'); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) {$field_array[] = mysql_field_name($fields, $i);} if (!in_array('$newgoalid', '$newgoaldate', $field_array)) { // IF non-existant column ALTER table to add goal columns if (empty($field_array)) { $result = mysql_db_query("ALTER TABLE 'goals' ADD `".$newgoalid."` TEXT NOT NULL, ADD '".$newgoaldate."' DATE") or die("Alter Error: ".mysql_error()); } } // INSERT data INTO new column's fields to add record (newgoal#, newgoaldate) $SQL = " INSERT INTO `goals` (`ID`, `username`, `".$newgoalid."`, `goaldate`) VALUES (`".$ID."`, `".$username."`, `".$newgoal."`, `".$newgoaldate."`) "; $result = mysql_query($SQL) or die("Insert Error: ".mysql_error()); // Go back succesfully to profile.php header ("Location: test.php"); } ?>
  9. This will be a stupid\easy one, but I'm just too new to decypher what this mysql error is referring to. Any assistance at all would be appreciated. Thank you in advance. "Insert Error: 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 ''ID', 'username', 'goal1', 'goaldate') VALUES ('', '', 'goalfield', '')' at line 1" ... if ($_SERVER['REQUEST_METHOD'] == 'POST') { $result = mysql_query(" SELECT * from login WHERE username = '$username' ") or die(mysql_error()); $row = mysql_fetch_array($result); $ID = $row['ID']; $username = $row['username']; $NumGoals = $row['NumGoals']; $NumGoals++; $newgoal = mysql_real_escape_string(htmlspecialchars($_POST['newgoal'])); $newgoalid = "goal"; $newgoalid .= $NumGoals; $newgoaldate = mysql_real_escape_string(htmlspecialchars($_POST['goaldate'])); // Verify if last column name already exists in table from databasename $fields = mysql_list_fields('databasename', 'goals'); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) {$field_array[] = mysql_field_name($fields, $i);} if (!in_array('$newgoalid', '$newgoaldate', $field_array)) { // IF non-existant column ALTER table to add goal columns if (empty($field_array)) { $result = mysql_db_query("ALTER TABLE 'goals' ADD '$newgoalid' TEXT NOT NULL, ADD '$newgoaldate' DATE") or die("Alter Error: ".mysql_error()); } } // INSERT data INTO new column's fields to add record (newgoal#, newgoaldate) $SQL = " INSERT INTO goals ('ID', 'username', '".$newgoalid."', 'goaldate') VALUES ('".$ID."', '".$username."', '".$newgoal."', '".$goaldate."')"; $result = mysql_query($SQL) or die("Insert Error: ".mysql_error()); // Go back succesfully to same page header ("Location: test.php"); } ...
  10. I've donated $5 bucks for your time (sorry I'm broke or I'd have given more). Cheers, Chris
  11. Thanks for the solution and the advice about escaping\specialchars, I was playing it safe, but upon reflection of your advice, it makes zero sense to validate it as you've mentioned. Cheers, Chris
  12. It's doing everything correctly, other than only allowing Reaction="AWESOME" increase in the mysql db. Any ideas on this, I thought it was straight forward, but it's illuding my eyes and probably right in front of me. Any direction would be appreciated extremely much. <? error_reporting (E_ALL); // Db Connection xxx // Get the Reaction $Reaction = mysql_real_escape_string(htmlspecialchars($_GET['Reaction'])); // Get IP $ip = $_SERVER['REMOTE_ADDR']; // Append IP to current column $Used_IPs = ''; $Used_IPs .= $ip . ', '; // Get previous URL $Link = $_SERVER['HTTP_REFERER']; // Check to see if already voted based on IP and reference link $voted=mysql_num_rows(mysql_query(" SELECT Used_IPs FROM Reactions WHERE Link='$Link' AND Used_IPs LIKE '%".$ip."%' ")); if (empty($voted)) { // Get current row $result = mysql_query(" SELECT * FROM Reactions WHERE Link='$Link' ") or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); // Update Reaction if ($Reaction == 'AWESOME') { $AWESOME = $row['AWESOME']; $AWESOME++; mysql_query(" UPDATE Reactions SET AWESOME='$AWESOME', Used_IPs='$Used_IPs' WHERE Link='$Link' ") or die (mysql_error()); } if ($Reaction == 'LOL') { $LOL = $row['LOL']; $LOL = $LOL++; mysql_query(" UPDATE Reactions SET LOL='$LOL', Used_IPs='$Used_IPs' WHERE Link='$Link' ") or die (mysql_error()); } if ($Reaction == 'CUTE') { $CUTE = $row['CUTE']; $CUTE = $CUTE++; mysql_query(" UPDATE Reactions SET CUTE='$CUTE', Used_IPs='$Used_IPs' WHERE Link='$Link' ") or die (mysql_error()); } if ($Reaction == 'WTF') { $WTF = $row['WTF']; $WTF = $WTF++; mysql_query(" UPDATE Reactions SET WTF='$WTF', Used_IPs='$Used_IPs' WHERE Link='$Link' ") or die (mysql_error()); } if ($Reaction == 'FAIL') { $FAIL = $row['FAIL']; $FAIL = $FAIL++; mysql_query(" UPDATE Reactions SET FAIL='$FAIL', Used_IPs='$Used_IPs' WHERE Link='$Link' ") or die (mysql_error()); } if ($Reaction == 'LAME') { $LAME = $row['LAME']; $LAME = $LAME++; mysql_query(" UPDATE Reactions SET LAME='$LAME', Used_IPs='$Used_IPs' WHERE Link='$Link' ") or die (mysql_error()); } } mysql_close($con); header("Location: {$_SERVER['HTTP_REFERER']}"); ?>
  13. With your guys' help I've got it to update, but now I'm royally confused as to make it header redirect because of the current output. Any suggestions on this coding? <!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" /> <script type="text/javascript" src="js/jquery-1.3.1.min.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.dropdownPlain.js"></script> <script> function validateForm() { var x=document.forms["ArticleSubmitter"]["Title"].value if (x==null || x=="") { alert("You must fill out the Blog Title."); return false; } var x=document.forms["ArticleSubmitter"]["Summary"].value if (x==null || x=="") { alert("You must fill out the Blog Summary."); return false; } var x=document.forms["ArticleSubmitter"]["BlogEntry"].value if (x==null || x=="") { alert("You must fill out the Blog Entry."); return false; } } </script> <title>Update Commentary Blog</title> </head> <body> <?php include('connect-cb.php'); // Get the user id if (is_numeric($_GET['ID'])) { $ID=$_GET['ID']; } // Get data from user with the specified id $result = mysql_query("SELECT * FROM TestCommentaryBlog WHERE ID='$ID'") or die ('Error Getting User Data! <br />' .mysql_error()); $numrows = mysql_num_rows($result); $row = mysql_fetch_array($result); // If user id returns no results if ($numrows != 1) { echo 'ID: <b>'.$ID.'</b> does not exist!'; return false; } else { // Edit Form $result = mysql_query("SELECT * FROM TestCommentaryBlog WHERE ID=$ID") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $Title=$row['Title']; $Title=str_replace('"','"',$Title); $Category=$row['Category']; $Summary=$row['Summary']; $Summary=str_replace('"','"',$Summary); $BlogEntry=$row['BlogEntry']; $BlogEntry=str_replace('"','"',$BlogEntry); $Image=$row['Image']; } } ?> <!-- Edit Form --> <form method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <td colspan="2"><h3>Edit and Submit</h3> <form action="view.php" method="post" onsubmit="return validateForm();> <input type="hidden" name="ID" value="<? echo "$ID" ?>"> </td> </tr> <tr> <td valign="top">Blog Title: </td> <td><input type="text" name="Title" size="100" value="<? echo "$Title"?>"></td> </tr> <tr> <td valign="top">Blog Category: </td> <td> <select name="Category"> <option value="Entertainment" <?php if($Category=="Entertainment") { echo "selected"; }?>>Entertainment</option> <option value="Humourous" <?php if($Category=="Humourous") { echo "selected"; }?>>Humourous</option> <option value="Other" <?php if($Category=="Other") { echo "selected"; }?>>Other</option> <option value="Politics" <?php if($Category=="Politics") { echo "selected"; }?>>Politics</option> <option value="Sports" <?php if($Category=="Sports") { echo "selected"; }?>>Sports</option> <option value="Technology" <?php if($Category=="Technology") { echo "selected"; }?>>Technology</option> </select></td> </tr> <tr> <td valign="top">Blog Summary: </td> <td><textarea name="Summary" rows="5" cols="76"><? echo "$Summary"?></textarea></td> </tr> <tr> <td>Blog Entry:</td> <td><textarea name="BlogEntry" rows="5" cols="76"><? echo "$BlogEntry"?></textarea></td> </tr> <tr> <td>Image URL:</td> <td><input type="text" name="Image" size="100" value="<? echo "$Image"?>"></td> </tr> <tr> <td colspan="2" align="center"><input type="Submit" name="Update" value="Update"></form></td> </tr> </table> <!-- /Edit Form --> <? // If edit was hit if ($_SERVER['REQUEST_METHOD']=="POST") { $Title=mysql_real_escape_string(htmlspecialchars($_POST['Title'])); $Category=mysql_real_escape_string(htmlspecialchars($_POST['Category'])); $Summary=mysql_real_escape_string(htmlspecialchars($_POST['Summary'])); $BlogEntry=mysql_real_escape_string(htmlspecialchars($_POST['BlogEntry'])); $Image=mysql_real_escape_string(htmlspecialchars($_POST['Image'])); mysql_query(" UPDATE TestCommentaryBlog SET Title='$Title', Category='$Category', Summary='$Summary', BlogEntry='$BlogEntry', Image='$Image' WHERE ID='$ID' ") or die ('Error Updating Data! <br />' .mysql_error()); // once saved, redirect back to the view page header("Location: view.php"); } ?> </body> </html>
  14. Ok, I've tried changing it as you've suggested, and also simply by naming the button but neither are functioning. Here is the code I have. Sorry for being terribly lame at this, it's a site for my brother otherwise I'd be too pissed off to work on it: <?php include('connect-cb.php'); // Get the user id $id = $_GET['id']; // Get data from user with the specified id $result = mysql_query("SELECT * FROM TestCommentaryBlog WHERE id='$id'") or die ('Error Getting User Data! <br />' .mysql_error()); $numrows = mysql_num_rows($result); $row = mysql_fetch_array($result); // If edit not hit if ($_SERVER['REQUEST_METHOD']!="POST") { // If user id returns no results if ($numrows < 1) { echo 'ID: <b>'.$id.'</b> does not exist!'; } else { // Edit Form $result = mysql_query("SELECT * FROM TestCommentaryBlog WHERE id=$id") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $Title=$row['Title']; $Title=str_replace('"','"',$Title); $Category=$row['Category']; $Summary=$row['Summary']; $Summary=str_replace('"','"',$Summary); $BlogEntry=$row['BlogEntry']; $BlogEntry=str_replace('"','"',$BlogEntry); $Image=$row['Image']; } } ?> <!-- Edit Form --> <form method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <td colspan="2"><h3>Edit and Submit</h3> <form action="" method="post" onsubmit="return validateForm();> <input type="hidden" name="id" value="<? echo "$id" ?>"> </td> </tr> <tr> <td valign="top">Blog Title: </td> <td><input type="text" name="Title" size="100" value="<? echo "$Title"?>"></td> </tr> <tr> <td valign="top">Blog Category: </td> <td> <select name="Category"> <option value="Entertainment" <?php if($Category=="Entertainment") { echo "selected"; }?>>Entertainment</option> <option value="Humourous" <?php if($Category=="Humourous") { echo "selected"; }?>>Humourous</option> <option value="Other" <?php if($Category=="Other") { echo "selected"; }?>>Other</option> <option value="Politics" <?php if($Category=="Politics") { echo "selected"; }?>>Politics</option> <option value="Sports" <?php if($Category=="Sports") { echo "selected"; }?>>Sports</option> <option value="Technology" <?php if($Category=="Technology") { echo "selected"; }?>>Technology</option> </select></td> </tr> <tr> <td valign="top">Blog Summary: </td> <td><textarea name="Summary" rows="5" cols="76"><? echo "$Summary"?></textarea></td> </tr> <tr> <td>Blog Entry:</td> <td><textarea name="BlogEntry" rows="5" cols="76"><? echo "$BlogEntry"?></textarea></td> </tr> <tr> <td>Image URL:</td> <td><input type="text" name="Image" size="100" value="<? echo "$Image"?>"></td> </tr> <tr> <td colspan="2" align="center"><input type="Submit" name="Update" value="Update"></form></td> </tr> </table> <!-- /Edit Form --> <? // If edit was hit if ($_SERVER['REQUEST_METHOD']=="POST") //if ($_POST['Update']) { $Title=mysql_real_escape_string(mb_convert_encoding($_POST['Title'])); $Category=mysql_real_escape_string(mb_convert_encoding($_POST['Category'])); $Summary=mysql_real_escape_string(mb_convert_encoding($_POST['Summary'])); $BlogEntry=mysql_real_escape_string(htmlspecialchars($_POST['BlogEntry'])); $Image=mysql_real_escape_string(htmlspecialchars($_POST['Image'])); mysql_query(" UPDATE TestCommentaryBlog SET Title='$Title', Category='$Category', Summary='$Summary', BlogEntry='$BlogEntry', Image='$Image' WHERE id='$id' ") or die ('Error Updating Data! <br />' .mysql_error()); // once saved, redirect back to the view page header("Location: view.php"); } } ?>
×
×
  • 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.