Jump to content

kamasheto

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kamasheto's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My internet connection died out on me last night after reading corbin's first post and I came to conclude his second method later on. Thank you very much my problem is now solved. @ MCP; I think I'm going to start using your nl2br function more often from now on, thanks for the heads up.
  2. Hey I have my form all set up, a wonderful textarea styled beautifully, and everything flows into the database like a charm. I check my database and the message lies right there exactly how I want it. However my problem arises when I call for the information and print it out again. If I pass to the database: "Hey How are you?" In the database it is stored: "Hey How are you?" But if I call for it and print out again, it says: "Hey How are you?" Now what am I missing here? Thanks for any feedback :)
  3. Could you show us your database structure, and you can add or die("something went wrong, error return is: ".mysql_error()); at the end of all the mysql_* functions to know exactly where the problem is.
  4. [code]<?php $user="blah"; $host="localhost"; $password="blahblah"; $database="blahblah"; // there was a " missing here mysql_connect($host,$user,$password); mysql_select_db($database); $q = mysql_query("select * from layouts order by id desc"); $n = mysql_num_rows($q); // we were counting $result, which isn't actually defined if (!$n) { print "No layouts found."; } else {     while ($r = mysql_fetch_array($q))     {     print "<table id='box_top'>     <tr>     <td>     <b>{$r['title']}</b>     </td>     </tr>     </table>         <table id='box'>     <tr>     <td valign='top'>     <img src='{$r['previewimage']}' width='160' height='110' border='0' alt=''>     </td>     <td valign='top' width='170'>     <b>Added</b>: {$r['date']}<br />     <b>Type</b>: {$r['type']}<br />     <b>Size</b>: {$r['size']}<br />     <b>Designer</b>: <a href='{$r['artisturl']}' target='_blank'>{$r['artist']}</a><br />     <b>Previews</b>: {$r['pcounter']}<br />     <b>Downloads</b>: {$r['dcounter']}<br /><br />         <a href='{$r['preview']}'><b>Preview</b></a> &nbsp; <a href='{$r['download']}'><b>Download</b></a>     </td>     </tr>     </table>     <br />"; } } ?>[/code]
  5. [code]<?php echo "<font style='color:red'>" . $BusinessName . "</font>"; ?>[/code]
  6. Nowhere, I already took care of that in the download.php file. Here's the scenario; You click here >> domain.com/download.php?id=4 Here's download.php [code]<?php $id = intval($_GET['id']); if($id) { $user="blah"; $host="localhost"; $password="blahblah"; $database="blahblah"; mysql_connect($host,$user,$password); mysql_select_db($database); mysql_query("UPDATE layouts SET dcounter=dcounter+1 WHERE id=".$id); // now for example change the header to the file you're downloading, forexample located here >> domain.com/file.zip header("Location: file.zip"); } else { print "something went wrong, you cannot download this file"; } ?>[/code]
  7. Try this instead; <a href='delete_category.php?id={$data[0]}' target=main> if it still doesn't work, try <a href='delete_category.php?id={$data['id']}' target=main> assuming id is your column name.
  8. For example let's say your download.php file looks something like this; [code]<?php $id = intval($_GET['id']); if($id) { // in this case my id is already assigned in the top of the page, I can directly use it down the script $user="blah"; $host="localhost"; $password="blahblah"; $database="blahblah"; mysql_connect($host,$user,$password); mysql_select_db($database); mysql_query("UPDATE layouts SET dcounter=dcounter+1 WHERE id=".$id); // notice I used $id, assigned in line 2 // now you can either print the download link or provide a download ticket // however way you do it, you have your download counter increased by one } else { print "something went wrong, you cannot download this file"; } ?>[/code] Makes any sense?
  9. Basically it saves query usage if you insert a name (or you called it a word?) What unique_id_column is, is just a column name in your table, it's doesn't actually matter what column you're calling for as long as your WHERE clause is correctly taken care of. For example, if my table looks like this; [table] [tr][td]id[/td][td]username[/td][td]password[/td][/tr] [tr][td]1[/td][td]kamasheto[/td][td]password[/td][/tr] [tr][td]2[/td][td]username[/td][td]password[/td][/tr] [/table] And I try registering the username kamasheto with this query; [code]SELECT id FROM members WHERE username='kamasheto';[/code] Then I'll get this row returning; [table] [tr][td]id[/td][/tr] [tr][td]1[/td][/tr] [/table] This when passed through mysql_num_rows(); will give me a true value of 1, which will produce an error as desired. If you decide you want to select * (means all the columns), your query; [code]SELECT * FROM members WHERE username='kamasheto';[/code] will return [table] [tr][td]id[/td][td]username[/td][td]password[/td][/tr] [tr][td]1[/td][td]kamasheto[/td][td]password[/td][/tr] [/table] Which when passed through mysql_num_rows() will give the same result, 1 returned row. The only limitation to calling a specific column(s) is that in your fetching process (using mysql_fetch_array with the while loop), you'll be able to only use those columns. For example in my first query where I called for ONLY the id, I cannot check for the password using that same query, I'll have to call for a new query hence. However with my second query, I can always fetch the entire array anytime down the script. Helpful enough?
  10. Shouldn't work, I wasn't paying attention to what your code should be doing (and that dcounter is the download counter and pcounter is your preview counter, and that neither should increase when this specific script is run) Anyway, here's what you should have; [code]<?php $user="blah"; $host="localhost"; $password="blahblah"; $database="blahblah; mysql_connect($host,$user,$password); mysql_select_db($database); $q = mysql_query("select * from layouts order by id desc"); $n = mysql_num_rows($result); if (!$n) { print "No layouts found."; } else {     while ($r = mysql_fetch_array($q))     {     print "<table id='box_top'>     <tr>     <td>     <b>{$r['title']}</b>     </td>     </tr>     </table>         <table id='box'>     <tr>     <td valign='top'>     <img src='{$r['previewimage']}' width='160' height='110' border='0' alt=''>     </td>     <td valign='top' width='170'>     <b>Added</b>: {$r['date']}<br />     <b>Type</b>: {$r['type']}<br />     <b>Size</b>: {$r['size']}<br />     <b>Designer</b>: <a href='{$r['artisturl']}' target='_blank'>{$r['artist']}</a><br />     <b>Previews</b>: {$r['pcounter']}<br />     <b>Downloads</b>: {$r['dcounter']}<br /><br />         <a href='{$r['preview']}'><b>Preview</b></a> &nbsp; <a href='{$r['download']}'><b>Download</b></a>     </td>     </tr>     </table>     <br />"; } } ?>[/code] If you're not going to do any changes on the values retrieved from the database it's useless to store them in a different variable. You can just use the return value instead. However, on preview/download, you should add this code to increase the counter in the table accordingly; This should be inserted in the download instance, you should pick what to add on your preview instance; [code]<?php // code to generate the download instance $id = 'something'; // here is the reference to where the script is going to get your layout id from mysql_connect($host,$user,$password); mysql_select_db($database); mysql_query("UPDATE layouts SET dcounter=dcounter+1 WHERE id=".$id); ?>[/code] Hope this is helpful enough.
  11. Or even better, download this >> http://www.php.net/get/php_manual_en.tar.gz/from/a/mirror
  12. I was just telling him how, no security involved. The way I'd normally do it is pass my $_POST array to a function that does all those fancy little checks and replacements before I use them anywhere, whether it's something as plain as this to print them back to the user or as severe as inserting them in a database.
  13. [quote author=jesirose link=topic=119769.msg490793#msg490793 date=1166907185] Save the values to the session. On the processing page, create an array, say $form. Then say $form['name'] = $_POST['name']; //Make sure to actually sanitize your data. Before redirecting back to the form with the error, do $_SESSION['form'] = $form; On the form page get the form out of the session: $form = $_SESSION['form']; In each of the inputs add value="<?=$form['name']?>" etc. [/quote]Pheww.. blame me for not having a clue what that is anyway, how I'd suggest you do it is to point your action to point your form to the file you're submitting from; here's how [code]<?php if(isset($_POST['submit'])) { $error = ""; if(!strlen($_POST['username'])) { $error .= "You need to enter a username<br />"; } if(!strlen($_POST['password'])) { $error .= "You need to enter a password<br />"; } if(strlen($error)) { showForm($error); } else { // process our input here } } else { showForm(); } function showForm($e="") { if(strlen($e)) { $e = "<font class='error'>".$e."</font>"; } else { $e = ""; $_POST = NULL; } print "<html> <head> <title>My Test Form - kamasheto</title> <style>body { font-size:14px;font-family:Verdana, Sans } .error { font-variant: small-caps; }</style> </head> <body> {$e} <form action='?' method='post'> <input type='hidden' name='submit'> Username: <input type='text' name='username' value='{$_POST['username']}'><br /> Password: <input type='password' name='password' value='{$_POST['password']}'><br /> <input type='submit' value='login'> </form> </body> </html>"; } ?>[/code]
  14. [code]<?php $user="blah"; $host="localhost"; $password="blahblah"; $database="blahblah; mysql_connect($host,$user,$password); mysql_select_db($database); $query = mysql_query("select * from `layouts` order by id desc"); $numb = mysql_num_rows($result); if (!$numb) { echo "No layouts found."; } else {     while ($row = mysql_fetch_array($query))     {     $id=$row["id"];     $title=$row["title"];     $artist=$row["artist"];     $artisturl=$row["artisturl"];      $type=$row["type"];     $size=$row["size"];     $date=$row["date"];     $previewimage=$row["previewimage"];     $download=$row["download"];     $dcounter=$row["dcounter"];     $preview=$row["preview"] + 1;     $pcounter=$row["pcounter"] + 1;     mysql_query("UPDATE `layouts` SET `preview`=".$preview.",`pcounter`=".$pcounter." WHERE id=".$id);     echo "<table id='box_top'><tr>     <tr>     <td>     <b>$title</b>     </td>     </tr>     </table>         <table id='box'>     <tr>     <td valign='top'>     <img src='$previewimage' width='160' height='110' border='0' alt=''>     </td>     <td valign='top' width='170'>     <b>Added</b>: $date<br />     <b>Type</b>: $type<br />     <b>Size</b>: $size<br />     <b>Designer</b>: <a href='$artisturl' target='_blank'>$artist</a><br />     <b>Previews</b>: HERE<br />     <b>Downloads</b>: HERE<br /><br />         <a href='$preview'><b>Preview</b></a> &nbsp; <a href='$download'><b>Download</b></a>     </td>     </tr>     </table>     <br />"; } } ?>[/code]
  15. [code]<?php // the action='' value in your html form leads to here // assuming the name of the input where your home address goes is called home_address $home_address = $_POST['home_address']; // assuming same as above but billing address is called billing_address $billing_address = $_POST['billing_address']; // now let's check if(strlen($billing_address)) { $home_address = $billing_address; } else { // don't do anything, thanks } // continue our processing // let me make this clear, if someone enters a blank space in the billing address, you'll have virtually a string in both variables // but literally, nothing in both ?>[/code]
×
×
  • 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.