Jump to content

watsmyname

Members
  • Posts

    226
  • Joined

  • Last visited

Posts posted by watsmyname

  1. @MDanz - We're just trying to help here man, (I know I haven't provided you any help) but please remember this is a FREE forum with many people who are more than willing to help you out if you allow them to. TLG is trying to.

     

    srry wasn't meant to be rude.. just frustrated

    well it doesnt seem practical you want to save search results in the table as it is already in your database. So why dont you save each keyword user searches in another table, and later select all search items with these keywords?

  2. umm, im making a game and characters HP so far is just text how would i make an image of about 1px X 5px show if the hp is 50 it would show 50 times like this:

     

    HP 50/100

    bar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.pngbar_green.png

     

    could anyone help me?

    <?php $hp=$_GET["hp"]; ?>

    <img src='line.jpg' width='<?php echo $hp; ?>' height='5px' />

     

  3. I scrapped the custom MySQL class and reverted back to standard php and got it all working. the reason i persisted with the custom class was because i had other functions used in the file that accessed the class.  I cant for the life of me figure out why this is the only file that cant access the functions.  But got it all working, so thanks for the replys.

    then you might have called wrong method of a class to execute select query.

     

    in custom class, there might method get_var or get_results or get_row or something like that, so if these methods exist you should use like $db->get_row($sql)

  4. Hello,

    Is it just me or are you ending the else statement as soon as you started it?

     

    <?php
       if($_POST['submit']) {
          $db = mysql_connect($dbhost, $dbuser, $dbpassword);
          mysql_select_db($dbdatabase, $db);
          $sql = "INSERT INTO comments(blog_id, dateposted, name, comment) VALUES(". $validentry . ", NOW(),'" . $_POST['name'] . "','" . $_POST['comment'] . "');";
          mysql_query($sql);
          header("Location: http://" . $HTTP_HOST . $SCRIPT_NAME . "?id=" . $validentry);
       }
       else {
       }//Here...
    ?>
    

     

    Try putting the ending curly bracket at the end of everything, after the closing HTML tags for example.

     

    Such as here:

    <?php
          require("footer.php");
    }//Close the else statement.
       ?>
    

     

    Hope it helps.

    well nothing wrong with his code, its not necessary you need to write something inside else condition

    but he should have omitted else part, in current scenerio its not necessary.

  5. Hi

    I want to delete a row from a database without redirecting to a delete page, can i call a function from a link? or idealy have a javascript confirmation.

     

    echo "<tr>

    <td>$id</td>

    <td>$name</td>

    <td><a href=delete.php?id=$id >Delete</a> </td>

    </tr>";

    //repeat

    $i++;

    }

     

    thanks

    well you either have to redirect to the same page or the other page, if you dont want redirection use ajax.

  6. Hi,

     

    Can someone help with this error.  I have researched here and on the web and it seems as tho there are alot of reasons for getting this error, most which stem from not having a database connection?? In my code below everything executes fine until the SELECT statement where i get a Fatal error: Call to a member function query() on a non-object in {FILEPATH} errorb] error. I have taken the SELECT query out and the data has been passed into the database,therefore i know there is a databse connection.  Is there any other reason this error is apprearing?

     

    <?php
    
      if(!$conn = mysql_connect($host,$user,$passwd)) die ("Unable to connect to database");
    
    //Select MySQL DB 
      if(!mysql_select_db($db,$conn)) die ("Unable to select database $db");
    
    $quote = $_POST['quote'];
    $text = $_POST['text'];
    $image = $_POST['image'];
    
    $page = $_GET['page'];
    
    
    $escimage = mysql_real_escape_string($image);
    $esctext = mysql_real_escape_string($text);
    $escquote = mysql_real_escape_string($quote);
    
    mysql_query("UPDATE content SET image = '$escimage', text = '$esctext', quote = '$escquote'
    WHERE page = '$page'");
    
    //Following error throws Fatal error: Call to a member function query() on a non-object in {FILEPATH} error
    $sql = 		"SELECT * FROM content 
       		WHERE page = '$thisPage'";
    		$result = $db->query($sql);
    ?>

    What is this?

    $result = $db->query($sql);

    i think you are using some custom class, have you included in the code?? if you're using the class, which class are you using?? Its likely you have called wrong method in a class.

  7. I dont get an error, i get a blank reply, even though i know the data is in the table.. i suspect the sql query?

    execute this query in your phpmyadmin and see if mysql throws any error

    SELECT * FROM medicine WHERE by = '$user'  //make sure to replace $user with the name

  8. Hi there, I've been searching for hours on how to properly do this. No luck so far!

     

    Anyways, I do not want to limit things to being only caps or only lowercase. I also do not want to write out every single possible word for filtering.

    Example:

    $word = "Swear Word";

    if(strstr($paragraph,$word)) {

    die($die_error);

    }

     

    I don't want to have to type this out 50 different ways like:

    SWEAR WORD

    SwEaR WoRd

    SWeaR WORd

    etc..

     

    I am unable to find a function where it will understand the word whether it is mixed, fully caps, or lowercase.

     

     

    I'm sure they have this for badword filters as people could just bypass the badword filter by typing a swear in via mixed case like "SwEaR WoRDs".

     

     

    Any help is appreciated :)

    well convert the user input to lowercase and check it against your list.

    forexample

     

    you have "swear word" in your list,

     

    $userword=strtolower($_GET["user_word"]);

    and check this $userword against your list

    hope you understood what i meant

  9. Hello, I am on an Asus Eee PC netbook running Windows XP, using XAMP.  I am finding that php files that are created on this computer are not interpreted by the browser, regardless of how they are created. 

     

    I am able to run the XAMP example PHPs fine, Joomla runs fine and PHP files that I created on other machines all run fine.  I tried using Windows Explorer to make an exact copy of a PHP script that runs and the code in the new file will not interpret. When I do a view source the PHP code shows. 

     

    If I use an editor – either Notepad, or Notepad++, and copy and paste the text in, the same thing happens and I've tried encoding in both ANSI and UTF-8.  Even a simple script with only the PHPINFO() function will not run.  :facewall:

    Xampp is the best,

     

    well make sure php short tags are enable in your php configuration file

    first try simple code

    <?php
    echo "This is test script";
    ?>
    

  10. I have done as you suggested but the echoed sentence is still not what the css says it should be.

    make sure your in.css is in includes folder.

     

    if still not working try to use inline style. like

     

    echo "<span style='font-family:Verdana, Geneva, sans-serif;font-size:10px;color:#ffcc00'>You Donated!</span>";

  11. I cant figure out where to put it in order to get no errors.

     

    Ive tried placing it inside the

    if(isset($_POST['submit']))

    main set of if statements as shown here:

    if(isset($_POST['submit']))
    {
        if(isset($_POST['title']) && empty($_POST['title'])){
            $error['title'] = 'Please enter a title';
        }
    if(isset($_POST['fname']) && empty($_POST['fname'])){
            $error['fname'] = 'Please enter your forename';
        }
         if(isset($_POST['sname']) && empty($_POST['sname'])){
            $error['sname'] = 'Please enter your surname';
        }
         if(isset($_POST['add1']) && empty($_POST['add1'])){
            $error['add1'] = 'Please enter the first line of your address';
        }
         if(isset($_POST['add2']) && empty($_POST['add2'])){
            $error['add2'] = 'Please enter the second line of your address';
        }
        if(isset($_POST['county']) && empty($_POST['county'])){
            $error['county'] = 'Please enter your county';
        }
        if(isset($_POST['pc']) && empty($_POST['pc'])){
            $error['pc'] = 'Please enter your postcode';
        }
        if(isset($_POST['email']) && empty($_POST['email'])){
            $error['email'] = 'Please enter your email';
        }
    if (!$error)
    {mysql_query("INSERT INTO customer (title, fname, sname, add1, add2, county, pc, email) VALUES ('$_POST[title]','$_POST[fname]','$_POST[sname]','$_POST[add1]','$_POST[add2]','$_POST[county]','$_POST[pc]', '$_POST[email]')") or die('Error: ' . mysql_error());		 
    }
    }

     

    which works ok-ish untill i try and redirect the user to another page by using

    header( "Location: http://www.google.com" );

    and then it comes up with the following error, just above the text boxes for input:

    Warning: Cannot modify header information - headers already sent by (output started at /home/sites/foo/public_html/test/newcustomer.php:12) in /home/sites/foo/public_html/test/php/testvalid.php on line 56

    which corresponds directly to the statement i have just added.

     

    I cant find a suitable place to put this if statement.

     

    Any ideas?

     

    Thanks,

    Lucy

    Well your thread is too long to go through right now, if you get error then you can use javascript to redirect. So instead of header( "Location: http://www.google.com" ); use

     

    echo "<script>document.location.href='http://www.google.com';</script>";

    exit();

  12. sorry i dont think i have propley explained in the first stuff() function if that turns true it puts a 1 in $passed else 0 then i want it to be then passsed into the second function called function levelup($dbc,$cost,$passed) as u can see $passed should now have a 1 in or 0 so then in the script for the levelup function it can run or not depending on true or false

     

    use return $passed in function stuff instead of echo

    well your function stuff just returns 1 or 0, so you dont need to call stuff function. Just call levelup function like this

    levelup($dbc,$cost,stuff('hq',$dbc));

     

  13. Please look at an example below, it seems pretty easy, but it is driving me nuts. I m working on Multilevel networking project.

    -  I wanted to calculate commission for each member for making members upto four levels.

    -  If a person makes Corporate Members© then he get 10$ commission and if Individual(I) member are made then the person get $5 commission.

    - And these commissions are calculated on the monthly basis. Suppose the first member is John, then he won't receive commission unless he makes 10 1st level members. After he reaches 10 1st level members(members may be C and I ), he receives commission and if he makes or his members makes more members he will get monthly commission.

    -  Suppose in july he made 7 first level members then he won't receive commission.

    -  In august, he makes 3 first level members, then his commission starts as his 1st level members reaches 10.

    -  He then gets commissions from 2nd level, 3rd level and 4th level as well.

     

    Levels

     

    a) Level 1= The group of members made by himself

    b) Level 2= The group of members made by the members of a)

    c) Level 3= The group of members made by the members of b)

    d) Level 4= The group of members made by the members of d)

     

    Now, yesterday i wasted my whole day to break through with the logic for calculation, but still no output. Guys please any body give me a break through logic? I know i have to use recursive functions for these, but i just wanted the logic how it can be done?

     

    Thanks in advance

    watsmyname

     

     

  14. Can anyone see the problem here...

     

    $name=mysql_real_escape_string($_GET['comp']);
    $res=mysql_query("SELECT * FROM leaguecomments WHERE comp_name = '$name' ORDER BY date DESC");
    
    while($row=mysql_fetch_assoc($res)){
    
    $user=$row['user'];
    $comment=$row['comment'];
    $commentdate=$row['date'];
               
    $date=strtotime($commentdate);
    $final_date=date("g:i a", $date);  
    $final_date2=date("F j Y", $date);

     

    mysql_fetch_assoc(): supplied argument is not a valid MySQL

     

    I can't work it out?

    might be your query returned 0 record, you should check whether there are any records or not and if there are records then use loop to display.

  15. Hello, I have a website I programmed with PHP and MySQL. When I take a record from the database, one of the fields is a timestamp and the date is in the format 2009-08-04 17:08:37 or YYYY-MM-DD HH:MM:SS

     

    How do I change this so I can make it appear as 4th August 2009 on the site?

     

    thanks

    like this,

    <?php
    $date_frm_database="2009-08-04 17:08:37";
    $date=date("jS F Y",strtotime($date_frm_database));
    echo $date;
    ?>
    

     

  16. and I know it's connecting to the database because i have a last log in row that that php form is updating... please please help me get the sessions working

    Actually, I thought it was updating but its not now..

    check if session is set in login-exec.php,

    echo session instead of redirecting to members page and see.

  17. and I know it's connecting to the database because i have a last log in row that that php form is updating... please please help me get the sessions working

    well try to echo ID session in member-index.php before the included auth.php file and see if you can get session value.

  18. Right, Thanks 'whatsmyname'. The second code worked perfectly.

     

    Now I just need help in only displaying the table if there are results.

    Also, all comments for my website are in one table so I cannot use odd/even numbers to define things. My MySQL table may look like this:

     

    id    blogid  comment

    1        5        .........

    2        8        .........

    3        5        .........

    same code works, i have put a condition, if there are result then it shows otherwise it shows "no result"

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