Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Posts posted by The Little Guy

  1. I have more than one computer, and I would like to network them for my website, what is the best way to this? One of the computers doesn't have an Ethernet port, the other 2 do.

     

    I have never done this before, so any help would be nice!

     

    Thanks.

  2. I am not usually a fan of deleting data from a table, and I don't recommend doing it (but it also depends on what the table is for). You should have a toggle field, set it to "1" for an active user, or "0" for an inactive/deleted user.

     

    <?php
    if (isset($_POST['escape']) || (isset($_POST['suicide']))) {
            // Why here is nothing wrote ???
    }elseif(empty($_POST['agree'])){
    echo "You need to check the box";
    }else{
    mysql_query("update users set is_active = 0 where id = ".(int)$_SESSION['user_id']);
    }
    ?>

  3. Try this:

     

    <?php
    $haystack = $_GET[q];
    $query ="SELECT * FROM research_job_searches";
    $result=mysql_query($query)
      or die ("Connection to database table failed. 35. "  . mysql_error());	
    $nrows=mysql_num_rows($result);
    
    if ($nrows > 0){
    while($record = mysql_fetch_array($result, MYSQL_BOTH)){
    	$needle = $record[research_job_search_url_keyword] . "-jobs";
    	echo $needle."<br>";
    }
    }
    ?>

  4. I am trying to test whether or someone clicks on the button or not in a popup window I tried this, but it doesn't work:

     

    var mw = window.open("http://facebook.com/sharer/sharer.php?u="+window.location.toString(), 'facebook', 'status=0,toolbar=0,height=350,width=550,scrollbars=no,resizable=no');
    $(mw.document).load(function(){
    $(document).click(function(){
    	alert("hi");
    });
    });

     

    Is this even possible?

  5. I just realized that you have a select in the query, give this a try (I didn't try it, I don't even know if it is a valid query):

     

    INSERT INTO table_members (name) values ((SELECT application.Name FROM application WHERE application.ID = '$member')) ON DUPLICATE KEY UPDATE table_members.name = values(table_members.name)

  6. cURL and file:

     

    $url = "http://someurl.com/something";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETRUNTRANSFER, ture);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, ture);
    $opt = curl_exec($ch);
    
    $handle = fopen("myfile.txt", "wb");
    fwrite($handle, $opt);
    fclose($handle);

  7. create 2 tables, one for the users, and one for each website.

    The users table would have a user id and info about each user and a unique id.

    The website table would have a unique website id and who owns it along with the status and priority.

     

    something like this:

    <?php
    $sql = mysql_query("select * from users u left join websites w on(u.userid = w.userid)");
    $users = array();
    while($row = mysql_fetch_assoc($sql)){
    $users[$row['userid']][] = $row;
    }
    print_r($users);
    ?>

  8. Here is some code I just wrote

    <?php
    function jpgThumb($orig_file, $save_file, $thumb_width, $quality = 75){
    // Create a copy of the original image and save it into memory for later manipulation
    $main = imagecreatefromjpeg($orig_file);
    
    // Calculate the thumbnail's height/width based off the original images' height/width
    $info = getimagesize($orig_file);
    $width = $info[0];
    $height = $info[1];
    $new_height = $height * ($thumb_width / $width);
    
    // Create a blank thumbnail with our new height and width
    $thumb = imagecreatetruecolor($thumb_width, $new_height);
    
    // Resize the main image and place it on the thumbnail from the previous line.
    imagecopyresampled($thumb, $main, 0, 0, 0, 0, $thumb_width, $new_height, $width, $height);
    
    // Save the image thumbnail
    imagejpeg($thumb, $save_file, $quality);
    }
    
    jpgThumb("CapCom.jpg", "thumbs/CapCom.100.jpg", 100);
    jpgThumb("CapCom.jpg", "thumbs/CapCom.200.jpg", 200);
    ?>

     

    If you read though my comments above, it is fairly simple to create a thumb based on a jpeg. If you modify it, you can also work with png's (with alpha support) and gif's (with transparency support).

  9. My regexp has an error, and I can't figure out where it is coming from.

     

    Parse error: syntax error, unexpected '.' in /home/ryannaddy/tutorials.phpsnips.com/incl/classes/Main.inc.php(87) : regexp code on line 1

     

    $string = preg_replace("/\[code\](.+)\[\/code\]/isUe", "'<span class=\"exampletxt\">EXAMPLE:</span><div class=\"code\">'.str_replace('<br />','',$1).'</div>';", $string);

     

    How would I fix that?

  10. I have the following function to format some code, I am having a problem though. between the code and example bbc tags new lines are converted to br's. I can't remember how to stop that from happening between those two tags, but do it everywhere else, can someone refresh my memory?

     

    My Attempt:

     

    public function format($string){
    $string = preg_replace("/\<\?php.+\?\>/isUe", "highlight_string(str_replace('\\\"', '\"', '$0'), true);", $string);
    $string = preg_replace("/\[code\](.+)\[\/code\]/isU", "<span class='exampletxt'>EXAMPLE:</span><div class='code'>$1</div>", $string);
    $string = preg_replace("/\[example=(.+)\](.+)\[\/example\]/isUe", "html_entity_decode('$2');", $string);
    $string = preg_replace('/(<br\s*\/*>)/is', '', $string);
    $string = nl2br($string);
    return trim($string);
    }

     

    Thanks!

  11. I am using jQuery and I have a drop down menu and when a user select the option "New Option" a text box is un-hidden they enter the new option, and press add. jQuery I send the value of the textbox to a php file which adds the option to the database, then I have a php function which rebuilds the drop down with the new value in it and the hidden box. I then add those to the page (over writing the old drop down and hidden textbox).

     

    The problem I am having is that I can do this one time the second time this no longer works unless I reload the page. What is causing this?

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