Jump to content

DanielHardy

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Everything posted by DanielHardy

  1. Oops, right you are. Simply remove the single quotes so it becomes: echo "www.google.com/".$your_field_from_database."therestofyoururl.com"; Or use jesirose' solution. So you actually know a little about what is going on here, concatenation involves printing one or more strings when they have other things inbetween them. The concatenation operator is the " . " dot simple you see above, which basically means "and".
  2. Thanks for the input guys. I'll give abdbuet's method a go and let you know my results.
  3. echo $row['PREF']; Trailing apostrophe missed from the row declaration in your code. Sorry to be picky but the smallest details can cause hours of head against wall!
  4. echo '"www.google.com/".$your_field_from_database."therestofyoururl.com"';
  5. Hi, I am looking for some general advice on whether this is good practice for a forgot password script. Firstly when a user clicks "forgot password" they are taken to a page where they are asked to enter their email and their security question answer. Upon success, a randomly generated password is created and sent in normal format in an email to users email, and stored in the database (overwriting their old password) in MD5 format. Thanks in advance Dan
  6. SOLVED, Was simply a case of specifying to the update function only to carry out the actions when the id is equal to one in the database. I.e Instead of $sql = "SELECT id,files,name,date,status,user FROM user1_files ORDER by id DESC"; $cookie = $_COOKIE['ID_my_site']; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); if($status==0){ while(list($id,$files,$name,$date,$status,$user)=mysql_fetch_row($result)){ $updated = FALSE; if(count($_POST) > 0){ $admin = $_POST['admin']; array_map('intval',$admin); $admin = implode(',',$admin); mysql_query("UPDATE user1_files SET status=1 WHERE id IN ($admin)") or trigger_error(mysql_error(),E_USER_ERROR); $updated=TRUE; echo "<meta http-equiv='refresh' content='1;URL=". $files ." ' />"; } } } I used if(count($_POST) > 0){ $admin = $_POST['admin']; array_map('intval',$admin); $admin = implode(',',$admin); $sql = "SELECT id,files,name,date,status,user FROM user1_files WHERE id IN ($admin)"; $cookie = $_COOKIE['ID_my_site']; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); if($status==0){ while(list($id,$files,$name,$date,$status,$user)=mysql_fetch_row($result)){ $updated = FALSE; mysql_query("UPDATE user1_files SET status=1 WHERE id IN ($admin)") or trigger_error(mysql_error(),E_USER_ERROR); $updated=TRUE; echo "<meta http-equiv='refresh' content='1;URL=". $files ." ' />"; } } }
  7. Sorry, Files contains the link to a file name. I's confusing as it is picking up the correct filename, date and id, but not linking to the correct path. [EDIT] files contains the link to a file path, not name [/EDIT]
  8. No, The id is fine, and works as it should. In short, it's picking up the right ID, but not the right $files.
  9. Thanks for your reply. I'm not sure that will help me. The redirect redirects to a database based URL. Let me explain. if($status==1){ echo '<div id="downloads" style="font-family:Arial;width:900px;height:30px;float:left;margin-bottom:5px;background-color:#cccccc;line-height:30px;"><div id="filename" style="float:left;padding-left:20px;width:600px;height:30px;border-right:5px solid #ffffff;">'.$name.'</div><div id="date" style="text-align:center;font-size:11px;float:left;width:125px;border-right:5px solid #ffffff;height:30px;">'.$date.'</div><div id="date" style="float:left;width:140px;text-align:center;font-size:11px;height:30px;"><a class="downloads" href="' . $files . '" title="Your File"><img src="viewed.png"></a></div></div>'."\n"; } The above code (for each) displays the name, date and URL of all database table objects where status = 1. This all displays fine and the "$files" variable does indeed link to where it should. However, When status equals 0, I am using the following code: $sql = "SELECT id,files,name,date,status,user FROM user1_files ORDER by id DESC"; $cookie = $_COOKIE['ID_my_site']; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); if($status==0){ while(list($id,$files,$name,$date,$status,$user)=mysql_fetch_row($result)){ $updated = FALSE; if(count($_POST) > 0){ $admin = $_POST['admin']; array_map('intval',$admin); $admin = implode(',',$admin); mysql_query("UPDATE user1_files SET status=1 WHERE id IN ($admin)") or trigger_error(mysql_error(),E_USER_ERROR); $updated=TRUE; echo "<meta http-equiv='refresh' content='1;URL=". $files ." ' />"; } } } to update the status to 1 when the button is clicked. However, the files variable for all objects is automatically redirecting to the id with the lowest id. I.e I want to link to the url associated with 6, it ill link to URL associated with 1. Thanks again Dan
  10. Hi All, I am dynamically producing output of submit buttons like this: echo '<div id="downloads" style="font-family:Arial;width:900px;height:30px;float:left;margin-bottom:5px;background-color:#069e0d;line-height:30px;color:#ffffff;"><div id="filename" style="float:left;padding-left:20px;width:600px;height:30px;border-right:5px solid #ffffff;">'.$name.'</div><div id="date" style="text-align:center;font-size:11px;float:left;width:125px;border-right:5px solid #ffffff;height:30px;">'.$date.'</div><div id="date" style="float:left;width:140px;text-align:center;font-size:11px;height:30px;"><input type="submit" name="admin[]" value="'.$id.'" style="height:30px;width:145px;border:none;background-image:url(download.png);color:transparent;background-color:#069e0d;"></div></div>'."\n"; } I need to somehow reproduce this, but use a href instead of the button. The "admin" value is used by the following piece of code: <?php mysql_connect("*******", "*******", "*****") or die(mysql_error()); mysql_select_db("***********") or die(mysql_error()); $sql = "SELECT id,files,name,date,status,user FROM user1_files ORDER by id DESC"; $cookie = $_COOKIE['ID_my_site']; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($id,$files,$name,$date,$status,$user)=mysql_fetch_row($result)){ $updated = FALSE; if(count($_POST) > 0){ $admin = $_POST['admin']; array_map('intval',$admin); $admin = implode(',',$admin); mysql_query("UPDATE user1_files SET status=1 WHERE id IN ($admin)") or trigger_error(mysql_error(),E_USER_ERROR); $updated=TRUE; header("Location: $files"); } } ?> All that does is update a value from 0 to 1 when the button has been clicked. I want the same functionality but it does not seem to work when I replace the button with an image like follows: echo '<div id="downloads" style="font-family:Arial;width:900px;height:30px;float:left;margin-bottom:5px;background-color:#069e0d;line-height:30px;color:#ffffff;"><div id="filename" style="float:left;padding-left:20px;width:600px;height:30px;border-right:5px solid #ffffff;">'.$name.'</div><div id="date" style="text-align:center;font-size:11px;float:left;width:125px;border-right:5px solid #ffffff;height:30px;">'.$date.'</div><div id="date" style="float:left;width:140px;text-align:center;font-size:11px;height:30px;"><a href="' .$files . '" name="admin[]" value="'.$id.'" style="height:30px;width:145px;border:none;background-image:url(download.png);color:transparent;background-color:#069e0d;"></a></div></div>'."\n"; } Hope that all makes sense Thanks in advance Dan
  11. EXACTLY what I wanted! Updated code if you are interested: <?php $booked = "<b>Seat Booked</b>"; $sql = "SELECT id,title,message,date_added FROM messages2 ORDER BY id "; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $last_title = ''; while($row = mysql_fetch_assoc($result)){ $test = $row['message']; if($last_title != $row['title']){ echo "<h2>".$row['title'] . "</h2>"; $last_title = $row['title']; } echo $row['date_added']; echo '<input id="'.$test.'" type="radio" name="admin[]" value="'.$id.'" onclick="javascript:document.form22.car.value=this.id" >'."\n"; } ?> Feel free to view it on the site too! Thanks again, can see why you are recommended.
  12. Hi all, I have a script that is essentially a log file of all preious versions of an article (versioning) You can see the script I am talking about in action at: http://danielrhyshardy.com/AWT/forumadmin.php What I would like to do is, instead of displaying the title of each instance (you will see there are two instances named "apple", as they are two previous versions of an article), I would like to display that title once, and then all of the instances of that title be displayed below. I hope that makes sense. Here is the code <? $sql = "SELECT id,title,message,date_added FROM messages2 ORDER BY id "; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($id,$title,$message,$date_added)=mysql_fetch_row($result)){ echo '<div style="color:#bb0000;width:250px;text-align:center;float:left;margin-left:15px;margin-bottom:15px;padding-bottom:20px;"><b>'.$title.'<br>'.$date_added.'</b> <input id="'.$message.'" type="radio" name="admin[]" value="'.$id.'" onclick="javascript:document.form22.car.value=this.id" > </font></div>'."\n"; } ?> I would use something like if ($title = "apple") { but this would obviously not work for new posts, unless I wanted to constantly update my code. I am sure there is a simple way to achieve this. Perhaps someone can tell me!? Thanks in advance Dan
  13. Perhaps I can use an "AND, OR" somewhere? Ideas please guys
  14. Hi all, I have the following mysql delete query that essentially deletes a row from two seperate tables "messages" and "messages2" where the id is equal to that in both of the tables. The problem I am getting (for obvious reasons) is that it will only delete from the table, if it indeed exists in both tables. Here is the query: DELETE FROM messages,messages2 USING messages,messages2 WHERE messages.id = messages2.id AND messages.id = ?; How would I go about setting it so that the query always deletes from table "messages" and only deletes from "messages2" when a corresponding id exists? I think it would involve an IF EXISTS clause, but I am not sure on this, or indeed how to implement it. Thanks in advance guys Dan
  15. Hi all, I have written a fairly simple update script. Each new "topic" from the database is dragged up from the database and displayed with a radio button. The user then clicks a radio button (chooses a topic to edit), and they can then type new text into a textbox that will update that article when submitted. This is working fine, but what I want to do is place the "message" of the selected radio button in the textbox (so it can be directly edited) using an onclick event (yes I realise or this is javascript) or equivelent. I already have the data printing to the page so hopefully this will be an easy one for someone out there. Code below: <?php mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error()); $updated = FALSE; if(count($_POST) > 0){ $admin = $_POST['admin']; array_map("intval",$admin); $admin = implode(",",$admin); $user = $_COOKIE['ID_my_site']; $message = $_POST['message']; if (isset($_POST['admin'])) { mysql_query("UPDATE messages SET message='$message' WHERE id = '$admin'") or trigger_error(mysql_error(),E_USER_ERROR); $edit = mysql_query("SELECT message FROM messages"); if($id=='1'){ echo ("$edit"); } echo "<script language=javascript>alert('Post updated!')</script>"; $updated=TRUE; header( 'Location: forum.php' ) ; } else { echo "<script language=javascript>alert('You did not select a post!')</script>"; } } ?> <form name="form22" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin-top:40px;"> <?php ?> <?php $booked = "<b>Seat Booked</b>"; $sql = "SELECT id,title,message FROM messages ORDER by id DESC"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($id,$title,$message)=mysql_fetch_row($result)){ echo '<div style="border:5px dashed #ff0000;width:250px;text-align:center;float:left;margin-left:15px;margin-bottom:5px;padding-bottom:5px;"><b><font color="black"><h2>'.$title.'</h2></b><p> '.$message.'</p><input id="chk" type="radio" name="admin[]" onclick="javascript:document.form22.car.disabled=false" value="'.$id.'" /></font></div>'."\n"; } ?> Plus the textbox code should you need it: <textarea id="car" name="message" onkeyup="valsub()" disabled style="width:830px;"><? echo "cheese"; ?></textarea><p> <input id="btn" type="submit" name="submit" value="Edit Post" disabled /> You can see the working script at: http://danielrhyshardy.com/AWT/forumedit.php Thanks in advance guys Dan
  16. decode didn't work. The file accepts the $ symbol, and almost every other symbol, but for some reason not the £. Are there any other suggestions guys?
  17. The £ sign is being edited in the browser and saved to a html file (this html file has no html coding, or indeed a charset). The html files contents are then echoed back onto the screen. In short, i think it is using its html entity instead, how do i combat this?
  18. Code is usually helpful, but i thought it would be mainly unecessary as this seems to be a configuration problem. It displays that character fine when simply typed in html, it's the php echo that causes the issue......
  19. I know this is a common problem. I did also have a problem with the browser adding backslashes around apostrophies, but this was solved by editing the magic quotes setting. However I am still having trouble adding the £ symbol. Let me know if you need any code. Thanks
  20. Much simpler solution was to simply use: echo $codeToBeEdited5; There is a problem in that you have to refresh the page before the changes take effect, but this isn't a problem as this is an admin section, so when you log out, the changes will have taken efect. Thanks for your help
  21. Could you possibly expand your reply a little for me? I am struggling to follow it being a relative javascript novice Thanks in advance
  22. Hi All, My first post here for a while. I have created a cms so to speak. It uses a simple login system and ajax so that an admin can edit the text on the page, this then updates a html file that stores the text, and the actual page simply echos the html text. If you navigate to: http://moroccannatural.com/rhassoul.php You will see that the £7.50 price at the bottom is editable. When this is edited, I of course need it to update the amount value in the paypal form. The form is here: <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="float:left;padding-left:15px;"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="[email protected]"> <input type="hidden" name="lc" value="GB"> <input type="hidden" name="item_name" value="Rhassoul Clay 200g"> <input type="hidden" name="amount" value="7.50"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="button_subtype" value="products"> <input type="hidden" name="shipping" value=""> <input type="hidden" name="add" value="1"> <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest"> <input type="image" style="outline:none;" src="cart.jpg" name="submit2" onmouseover="javascript:this.src='cart2.jpg';" onmouseout="javascript:this.src='cart.jpg';"> </form> Here is the php that I think you will need to help : <?php $codeToBeEdited5 = file_get_contents('text5.html'); $idName5 = 'desc5'; require_once('AjaxEditInPlace.inc.php'); $ajaxEditInPlace = new AjaxEditInPlace($codeToBeEdited5, 'showText'); echo $ajaxEditInPlace->getEditInPlaceCode($idName5); ?> I have tried lots of things such as <input type="hidden" name="amount" value="<?php echo $idName5 ?> "> Please help me! Thanks Dan
  23. I used regiemon's method. Will remember to do this in future. The php code that included headers in my other page was indeed before the html. I also noticed that I was trying to redirect the page to itself in certain instances. So this was causing problems too. Thanks for all of your help.
  24. Using the Meta tags didn't work, interesting how you can use these in such a way though What piece of code are you suggesting I move exactly?
  25. Ideas on how to solve it without comprimising the functionality? Never come accross this before. Weird how it worked before though is it not? Thanks
×
×
  • 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.