Jump to content

rickyj

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Posts posted by rickyj

  1. okay, its a simple question, but I have no idea how to search for this.

     

    How can I put a forward slash within quotes.

     

    I have a problem, a string gets converted to "xyz/" and is then put in an sql querry, how can I detect the slash, I cant use: strpos($encPass, "\" ) > -1

    Since the \ makes the quotation a non surrounding quotaion.. so what can I use to detect a forward slash?

  2. for example :

     

    WHERE this_column Like '%srch%"'

     

    solves if  srch = "puzzle"

    and this_column = "a puzzle search phrase"

     

    but doesnt solve the case where

    for instance if srch = "this is a puzzle"

    and on one of the rows this_column = "a puzzle search phrase"

     

    - It might be possible to split srch, via ' ', and then check for each of the arrays eg:

     

    $splitSrch = split(' ', $srch)

      and then use:

    WHERE (this_column Like '%splitSrch[0]%'
             Or this_column Like '%splitSrch[1]%' ...)
    

    but $srch may not always contain two words... hmm, must be an easier way of doing this

  3. Does anyone know how to put the following in to a query

     

    WHERE At least one of the words in the phrase "srch" must contain at least on of the words  in "this_column"

     

    for instance if srch = "this is a puzzle"

    and on one of the rows this_column = "a puzzle search phrase"

    so the where statement is true for this row.

  4. my above code was supposed to say str_replace (The edit function was not working for me?). preg replace doesnt seem to work here for some reason?

     

    However, It should be noted, before I use these variables, I get them via this method:

     

    stripslashes((get_magic_quotes_gpc()) ? $_POST[$MyString] : addslashes($_POST[$MyString])));

  5. try this

    $string= preg_replace('/\r\n|\r|\n/', '<br>', $string);

     

    Thanks for the help,

    I tried this but get the following for:

    1st line

    new line

    third line

     

    gets converted to :1st line\r\nnew line\r\nthird line\r\n

    (looking at the database: looks exactly the same)

    i.e., it doesn’t get converted at all.

     

    yet,

    $string = preg_replace('\r', '<br>', $string);

    works but leave /n at the start of each line, and

    $string = preg_replace('\r\n', '<br>', $string);

    works, but deletes n's off of the start of a new line if its present <-- this I find really odd!

     

  6. Hi there, I’m having a real bit of trouble, and I cant narrow it down.

     

    I’m trying to get a form to post a message to a mySQL data base, and replace the users input new lines into <br>

     

    - But this doesn’t seem to  be working as expected.

    - I have tried lots of things, but they all give strange results.

    - the Mysql column is a text column

    - I have tried using nl2br, but this does nothing to the text.

     

    Im currently using:

    function nl2br2($string) {
        $string = str_replace('\r\n', '<br>', $string);
        $string = str_replace('\r', '<br>', $string);
        $string = str_replace('\n', '', $string);
        return $string;

     

    This works perfect, unless the new line start with an n, if the new line starts with an n the n gets striped:

     

    first line

    new line

    third

     

    gets converted to

     

    first line<br>ew line<br>third

     

    if I use this:

     

    function nl2br2($string) {
        $string = str_replace('\r\n', '<br>', $string);
        $string = str_replace('\r', '<br>', $string);
    
        return $string;

    I get:

    first line

    \nnew line

    \nthird

     

    I cant figure out whets going on here?

    I have also tried using variations, but get exactly the same result:

     

     

    function nl2br2($string) {
    $string = str_replace('\n\r\n', '<br>', $string);
    $string = str_replace('\r\n\n', '<br>', $string);
    $string = str_replace('\r\n', '<br>', $string);
        $string = str_replace('\r', '<br>', $string);
        $string = str_replace('\\n', '', $string);
        $string = str_replace('\nn', ' n', $string);
        $string = str_replace('\n', '', $string);
        return $string;

     

    gets converted to

     

    first line<br>ew line<br>third

     

    function nl2br2($string) {
    $string = str_replace('\n\r\n', '<br>', $string);
    $string = str_replace('\r\n\n', '<br>', $string);
    $string = str_replace('\r\n', '<br>', $string);
        $string = str_replace('\r', '<br>', $string);
        $string = str_replace('\\n', '', $string);
        $string = str_replace('\nn', ' n', $string);
        return $string;

    I get:

    first line

    \nnew line

    \nthird

     

    Any on know what is happening?

     

  7. Sorry, cant do that,

     

    but I can give examples (as the one above)

     

    Im bassically asking it there is a way of grabing the full url, since $_SERVER['PHP_SELF'] only grabs "/this.php" from www.example.come/this.php?other=things&more=1

     

    If I could grab the full url I would be able to show that 'other' and 'more' are or are not set without using isset, or get.

     

    I dont like using isset($_GET['a'] )

     

    since if the user manipulates the a variable to "a = ']) && more code //",  this is unsafe!

  8. hmm now Im getting :

     

    abDuplicate entry '119' for key 1

     

    what does this mean, my querry is now:

    print 'a';

    $Querry = "INSERT INTO sigparsed (a, b, c, d, e )  VALUES ('2', '$var1', '1', '$var2', '0' ) ";

    $result= mysql_query($Querry) or die(mysql_error());

    print 'b';

     

    $Querry2 = "INSERT INTO usertextfield (f, g)  VALUES ('$var3', '$var4') ";

    $result2= mysql_query($Querry2) or die(mysql_error());

    print 'c';

  9. this is the shothand sqlquerry(after connecting to the database an table):

     

    $result= mysql_query("INSERT INTO sigparsed (a, b, c, d, e )  VALUES ('2', $var1, '1', $var2, '0' ) ") or die(mysql_error());

    and my 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 '

     

    But I see nothing wrong with my syntext

  10. Hi,

     

    Im thinking of writting my own Text(picture) verification

     

    I know there are methods out there, but I dont want to use standards (since i know the common ones always get hacked eventualy).

     

    Im thinking of writting this in php, where the php gets a image number (say from the milliesecond that the user has gone to the registration of this page) eg, 01 millseconds = pic 1 (an algorithum will modify this, but you get the idea)

     

    But I have then run into security problems, with various approaches:

     

    1. onSend the javaScript can verify that the image the same as the input eg 01img = Myinput

    - security problem, javascript can be searched

     

    2. imageNumber can be varified by php that imageNumber corresponds to Myinput

    - cant see anyproblems with this so far

     

    Anyone done this before, any infomation on this sort of thing would be appreciated, thx

  11. from a securit point of view how is it possible to make sure that any post data only comes from one site (that you define)

     

    for instance if I had a example.MyRegistrationForm.php, which posts to example2.MyUserCreation.php

    How could I make sure that the data is only posted from example.MyRegistrationForm.php

     

    I dont want to send this in the post request (since post request can be manipulated), i need to find a way for  example2.MyUserCreation.php to know it come from example.MyRegistrationForm.php

     

    Any ideas?

  12. the above didnt work, it just set it to the first one, regardles of it already being present in the database! but I used:

     

      foreach ($ltURLarray as $ltURL) {

        $fetch=(mysql_query("SELECT `LT_URL` FROM `lt_users` WHERE `LT_URL`='".$ltURL."'"));

        if (empty($fetch['LT_URL'])) {

          break;

        }

      }

     

    why dont these posts merge :(

  13. I have something else that does the inserting, so the follwing code should work?

     

      foreach ($ltURLarray as $ltURL) {
        $fetch=mysql_fetch_assoc(mysql_query("SELECT `LT_URL` FROM `lt_users` WHERE `LT_URL`='".$ltURL."'"));
        if (empty($fetch['LT_URL'])) {
          break;
        }
      }

     

    // so now $ltURL is set to  $ltURLarray (where ltURLarray is not found)

     

    (sorry for me being a bit dumb and spelling it out in full), do you think this will work?

×
×
  • 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.