Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. You could have seriously made this a lot easier. If each page was, navigated by like:

     

    index.php?page=this

     

    And 'this' was an included file such as: includes/this.inc

     

    Whilst being an admin, have an admin-only link on the bottom of the page that would say "Edit this Page," then you would be prompted with like.

     

    admin.php?act=edit&page=this

     

    Using fread and fwrite, you can easily have the person just edit the file as a whole.

  2. Like I said before, they go inside the single quotes.

     

    <?php
    /*
    
    */
    
    // Define the webserver and path parameters
    // * DIR_FS_* = Filesystem directories (local/physical)
    // * DIR_WS_* = Webserver directories (virtual/URL)
    
    
    // add your database and website details to the variables below
    
    define('DB_SERVER_USERNAME', 'blahblah');
        // your username that you use to log into your web server
    define('DB_SERVER_PASSWORD', 'blahblah');
       // your password that you use to log into your web server
    define('DB_DATABASE', 'blahblah');
              // your database
    define('DIR_FS_ADMIN', '/home/myusername/public_html/admin/');
        // replace username with your web server username
    define('DIR_FS_CATALOG', '/home/myusername/public_html/');
    define('DIR_FS_DOCUMENT_ROOT', '/home/sitename/public_html/');
    define('SITE', 'www.sitename.net');
    define('WWW', 'http://www.sitename.net');
    define('HTTP_SERVER', 'http://www.sitename.net');
    define('HTTP_CATALOG_SERVER', 'http://www.sitename.net');
    
    
    define('DB_SERVER', 'localhost'); 
    
    ?>
    

  3. <?php
    /*
    
    */
    
    // Define the webserver and path parameters
    // * DIR_FS_* = Filesystem directories (local/physical)
    // * DIR_WS_* = Webserver directories (virtual/URL)
    
    
    // add your database and website details to the variables below
    
    define('DB_SERVER_USERNAME', ''); #blahblah
        // your username that you use to log into your web server
    define('DB_SERVER_PASSWORD', ''); #blahblah
       // your password that you use to log into your web server
    define('DB_DATABASE', ''); #blahblah
              // your database
    define('DIR_FS_ADMIN', '/home/username/public_html/admin/');  #blahblah
        // replace username with your web server username
    define('DIR_FS_CATALOG', '/home/username/public_html/'); #blahblah
    define('DIR_FS_DOCUMENT_ROOT', '/home/yoursite.com/public_html/'); #mysite.com
    define('SITE', 'www.yoursite.com'); #www.mysite.com
    define('WWW', 'http://www.yoursite.com'); #http://www.mysite.com
    define('HTTP_SERVER', 'http://www.yoursite.com'); #http://www.mysite.com
    define('HTTP_CATALOG_SERVER', 'http://www.yoursite.com'); #http://www.mysite.com
    
    
    define('DB_SERVER', 'localhost'); 
    ?>

     

    you replace the values INSIDE the quotes, not out side.

  4. You can easily modify this to fit what you need.

     

    <?php
    
    $string ="id<br>
    name<br>
    title<br>
    album<br>
    year<br>
    id<br>
    name<br>
    title<br>
    album<br>
    year<br>
    id<br>
    name<br>
    title<br>
    album<br>
    year<br>";
    
    $string = explode("<br>", $string);
    
    $x=1;
    
    foreach($string AS $alone){
    echo $alone . " ";
    
    	if($x == '5'){
    		echo "<br>\n";
    		$x=0;
    	}
    $x++;
    }
    ?>
    

     

    Of course, if it's a file. Just change the $string variable to

     

    $string = file_get_contents('file.txt');
    

     

    My results were:

     

    id name title album year 
    id name title album year 
    id name title album year 
    

  5. <?php
    # connect to your database
    
    $sql = "SELECT * FROM `list_cats` ORDER BY id";
    $res = mysql_query($sql) or die(mysql_error());
    
    while($row = mysql_fetch_assoc($res)){
    	echo "<div id=\"main_link\">{$row['name']}";
    		$sql2 = "SELECT * FROM `links` WHERE `cat`='{$row['id']}'";
    		$res2 = mysql_query($sql2) or die(mysql_error());
    		while($row2 = mysql_fetch_assoc($res2)){
    			echo "<div id=\"link\"><a href=\"/you/{$row2['link']}\"></div>\n";
    		}
    	echo "</div>\n";
    }
    ?>
    

     

    easily modifiable.

  6. This worked for me.

     

    <?php
    
    if(!$_POST['submit']){
    echo "<form method=\"post\" action=\"\">";
    echo "First: <input type=\"text\" name=\"fname\"><br>\n";
    echo "Last: <input type=\"text\" name=\"lname\"><br>\n";
    echo "<input type=\"submit\" name=\"submit\" value=\"Go\">\n";
    echo "</form>\n";
    }else {
    $fname = trim($_POST['fname']);
    $lname = trim($_POST['lname']);
    
    	if($fname && $lname){
    		echo "You have been added as " . $fname . " " . $lname;
    	}else {
    		echo "Missing one or two fields!";
    	}
    }
    ?>
    

  7. You can try this.

     

    <?php
    
    $ary = array(
    "Today date is 1, our breakfast is 2 eggs and salad",
    "Today date is 13, our breakfast is 3 breads and beff",
    "Today date is 18, our breakfast is 2 toasts with egg",
    "Today date is 21, our breakfast is 5 wafels with honey",
    "Today date is 30, our breakfast is a bowl of sereal"
    );
    
    $date = date("j");
    
    foreach($ary AS $ara){
    $ex = explode(" ", $ara);
    $ex = str_replace(",", NULL, $ex);
    
    if($ex[3] == $date){
    	$what = $ara;
    }
    }
    
    echo $what;
    
    ?>

     

    tested to some extent.

  8. The query is fine. Just add some protection to it.

     

    <?php
    
    $fname = mysql_real_escape_string(trim($_POST['prov_f_name']));
    $lname = mysql_real_escape_string(trim($_POST['prov_l_name']));
    
    if($fname && $lname){
    $sql = "INSERT INTO providers (`f_name`,`l_name`) VALUES('$fname','$lname');";
    $res = mysql_query($sql) or die(mysql_error());
    echo "You have been added as a provider successfully, " . $fname . " " . $lname;
    }else {
    echo "You did not supply a first name and/or last name!";
    }
    
    ?>
    

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