Jump to content

jrcarr

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

About jrcarr

  • Birthday 03/09/1956

Contact Methods

  • Website URL
    http://www.carrscorner.com

Profile Information

  • Gender
    Not Telling
  • Location
    Beautiful Arkansas Ozarks

jrcarr's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, how about taking the info from $_SERVER['SERVER_NAME'], which in the example given would be "/home/canter??/public_html/test/phpinfo.php" and find and remove everything from the last accurance of the "/" to the end, leaving only "/home/canter??/public_html/test".  If the script/file is run at: "/home/canter??/public_html/phpinfo.php" it would leave "/home/canter??/public_html" I'm just not sure what php command would look through a string and find the "last" accurance of a character and then replace everything from it to the end with "". Then with server name, I could do something like the following, using the "basename" like you mentioned: [code]$scriptLocation = "http://" . ($_SERVER['SCRIPT_FILENAME']). "/" .basename(dirname($_SERVER['SCRIPT_FILENAME']));[/code] Using the first example with a "test" directory, it should give me: [code]http://www.domain.com/test[/code] But if sitting in the root directory, it wouldn't work, since it would read like: [code]http://www.domain.com/public_html[/code] I can check for whether basename(dirname($_SERVER['SCRIPT_FILENAME'])) = "public_html"; and not include it, since not all servers are setup the same and it won't always be "public_html". Does any of this make sense and is it as difficult as I'm trying to make it? Jack
  2. I'm trying to figure out how to get the location that a file is executed.  For example, if I run a script in www.domain.com/test and have the following code: [code] <? echo $_SERVER['DOCUMENT_ROOT']. "<br>"; echo $_SERVER['SCRIPT_FILENAME']. "<br>"; echo $_SERVER['SERVER_NAME']. "<br>"; echo $_SERVER['SCRIPT_NAME']; [/code] [b]I get the following information:[/b] /home/canter??/public_html /home/canter??/public_html/test/phpinfo.php www.domain.com /test/phpinfo.php Now the info I need is, which is the actual location of the file being run: /home/canter??/public_html/test  ($_SERVER['SCRIPT_FILENAME'] minus the file name and the ending slash) http://www.domain.com/test    ($_SERVER['SERVER_NAME']+$_SERVER['SCRIPT_NAME'] minus the file name and the ending slash) I know this can't be that difficult, but I'm am drawing a total blank.  Thanks Jack
  3. and using the example table and date in the third post on this topic, what would be the syntax to use this command.  Thanks Jack
  4. Is this faster or have some other advantage to the method above?  I haven't researched the LOAD DATA INFILE command, so don't know anything about it. Jack
  5. Thanks.  What I'm trying to create is an installation routine to help users with the installation of a program I'm creating.  The install.php script will basically do the following: 1.  Display a form to collect their DB info, (name,user,password,server), default URL.... 2.  When form is submitted, it will create a setting.php file with the collected information and certain defaults. 3.  Then continuing after writing the file,  include ("settings.php") to get the info supplied and connect to the database and create the needed tables and fill them with just default info. The information going into the tables is the same on every installation and isn't dependent on anything in the form except for the DB connection info.  The rest of the program will add, edit, delete the info in the tables.  I'm pretty good or getting that way on working with DB information, but I have never needed to create tables from a script before.  I've always used phpMyadmin to handle that part. Again, Thanks Jack
  6. So, if I have this right, I would need to do something like the following to add a couple tables and then insert the info into them? [code]<?php   $conn = mysql_connect('localhost','username','password') or die(mysql_error());   $db = mysql_select_db('dbname',$conn) or die(mysql_error());   $sql = "CREATE TABLE website_catalogitems (`item_id` int(11) NOT NULL auto_increment, `catalog_id` varchar(50) NOT NULL default '', `item` varchar(100) NOT NULL default '', `info` text NOT NULL, birth DATE, `price` decimal(5,2) NOT NULL default '0.00', `thumbimage` varchar(100) NOT NULL default '',`image` varchar(100) NOT NULL default '', PRIMARY KEY  (`item_id`)); ";   $result = mysql_query($sql, $conn) or die(mysql_error());   $sql = "INSERT INTO `website_catalogitems` VALUES (1, '1', 'Sample Product', 'Birds', 10.99, '82d3bafaeef1a6446a8a7fd26cabird.jpg', '7c20a1390f2b080b0151ec6fb31bird.jpg');";     $result = mysql_query($sql, $conn) or die(mysql_error());   $sql = "CREATE TABLE different_name (Other fields list)";     $result = mysql_query($sql, $conn) or die(mysql_error());   $sql = "INSERT INTO `different_name` VALUES (different values for the fields in this table);";     $result = mysql_query($sql, $conn) or die(mysql_error()); ?> [/code] Then continue for all tables needed? Jack
  7. Well that only works if both databases are on the same domain/server.  But, I wanting to be able to create an installation routine that creates these tables on anyone's site.  So I can't just copy from one database to another.  Thanks for your reply Jack
  8. Can anyone give me the proper syntax using PHP to do this?  Thanks Jack
  9. if ($num1 == 0) { echo "you can't divide by 0"; } Jack
  10. Change your Else like the following: <?php $num1 = $_POST['num1']; $num2 = $_POST['num2']; if ($_POST['Submit1']) { echo "$num1 + $num2 = "; echo $num1 + $num2; } elseif ($_POST['Submit2']) { echo "$num1 * $num2 = "; echo $num1 * $num2; } ?> when I remove this part of the code: else ($_POST['Submit2']) { echo "$num1 * $num2 = "; echo $num1 * $num2; }
  11. Here is an example of one of the tables with the fields and the info that needs to be inserted. [code] CREATE TABLE `website_catalogitems` (   `item_id` int(11) NOT NULL auto_increment,   `catalog_id` varchar(50) NOT NULL default '',   `item` varchar(100) NOT NULL default '',   `info` text NOT NULL,   `price` decimal(5,2) NOT NULL default '0.00',   `thumbimage` varchar(100) NOT NULL default '',   `image` varchar(100) NOT NULL default '',   PRIMARY KEY  (`item_id`) ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `website_catalogitems` -- INSERT INTO `website_catalogitems` VALUES (1, '1', 'Sample Product', 'Birds', 10.99, '82d3bafaeef1a6446a8a7fd26cabird.jpg', '7c20a1390f2b080b0151ec6fb31bird.jpg'); [/code] I'm assuming that I would start with something like: [code]CREATE TABLE website_catalogitems (`item_id` int(11) NOT NULL auto_increment, `catalog_id` varchar(50) NOT NULL default '', `item` varchar(100) NOT NULL default '', `info` text NOT NULL, birth DATE, `price` decimal(5,2) NOT NULL default '0.00', `thumbimage` varchar(100) NOT NULL default '',`image` varchar(100) NOT NULL default '', PRIMARY KEY  (`item_id`));[/code] I don't know about the proper syntax and what to do with the ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; But then I'm guessing that I would run a query like: [code]INSERT INTO `website_catalogitems` VALUES (1, '1', 'Sample Product', 'Birds', 10.99, '82d3bafaeef1a6446a8a7fd26cabird.jpg', '7c20a1390f2b080b0151ec6fb31bird.jpg');[/code] But again, I'm unsure of exact syntax to make it work.  Then I would do the same basic thing with the other tables that I'm needing to load.  I'm also figuring that I would need to check to see if the table is already there, before trying to create and populate it, maybe drop the table if it is there and then re-create it. Does this give you some better idea of what I'm trying to do?  Thanks for the reply Jack
  12. I didn't know if this should be under PHP help or MySQL help.  Anyway... I've exported a set of tables with several fields in each, most of those field are poplulated.  Now, how would I use php to create those same tables, fields and populate them in another database? I know how to do it using phpmyadmin, but I want to be able to do it from an installation page script.  Thanks Jack
  13. I may be trying to make this more complicated than it is, but I'm not mentally coming up with exactly what it is I need here. I will try and explain this the best I can. I have a directory with a number of files, all being .php. Each week, there is one new file added to the directory. I want to be able to read in all the filenames of the files in this directory, then then output the list into 3 even colums of file names, with the necessary <a></a> so that a visitor can click on it to view the contents of the file. I know this can be easily done on a static page, but there are currently 170 files and 1 new one every week. I am trying to avoid having to update the page every week to add the new file. So can anyone give me the basic code to: 1. Read the filenames of all files in a directory into an Array[] 2. start page 3. Calculate 3 equal number of files to list in three colums 4. finish page I hope this makes sense, but if not feel free to ask for clarification. Jack
  14. Hello, I've gotten pretty good a programming in PHP, however, my Javascript leaves a lot to be desired. I'm looking for a way to run a small PHP function with a just a mysql_query if someone closes the browser window or leaves the page and navigates to another page. I'm assuming I need to use onunload() in the body tag, but I don't know if I can use it to call a PHP function directly or if I need to create a Javascript function, that calls a php function. If this is possible, could someone show me some basic code to achieve this. Thanks in advance Jack
  15. [!--quoteo(post=339326:date=Jan 24 2006, 07:17 AM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Jan 24 2006, 07:17 AM) [snapback]339326[/snapback][/div][div class=\'quotemain\'][!--quotec--] it's not picking up & because it's interpreted as part of the first query, not the second one. When you pass a url to a query string, you have to rawurlencode() it first. try this link: [a href=\"http://www.carrscorner.com/link/test.php?new=http://www.marinecanvas.com/index.php?option=weblinks%26topid=0\" target=\"_blank\"]http://www.carrscorner.com/link/test.php?n...links%26topid=0[/a] [/quote] Thank you very much, that looks like the solution. You are a scholar and a gentleman. Jack
×
×
  • 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.