[PHP-DB] Error when trying to connecting to an Oracle database
I am trying to use a program written in PHP but connect to an Oracle database. We have a function as follows: function dbconnect($db, $username, $password) { global $siteadmin; global $db; // $bob = @mysql_connect($db, $username, $password); //$bob= oci_connect($username, $password, $db); // mysql_select_db($db, $bob); $bob = oci_connect(, , devl); echo $bob; return $bob; } where is replaced with a username and is replaced with a password. We get the following error: Fatal error: Call to undefined function: oci_connect() in /www/WEBUSERS/ics2004/public_html/PHP/Project Manager/dba_copy(1).php on line 52 Line 52 is $bob = oci_connect(, , devl); Can anyone tell me why I am getting this error? Thanks Jan Smith Programmer Analyst Indiana State University Terre Haute, Indiana Phone: (812) 237-8593 Email: [EMAIL PROTECTED] *** This email, and any attachments, thereto, is intended only for use by the addressee(s) named herein and may contain privileged and/or confidential information. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Warnings and Notices
Jason Davis wrote: I just got the software I was fighting with working. Only issue now is that the top of the page is filled with notices and warnings, even though the code is working. Is there any way to turn off or hide these notifications? You can set the error level in php.ini, using the description there. You can also set the error level per script, as follows: http://www.php.net/manual/en/function.error-reporting.php You can stop errors being displayed altogether. See display_errors in your php.ini file. You can send your errors to a log file. http://www.php.net/manual/en/function.error-log.php You can stop individual warnings and messages by putting a @ in front of them. Janet -- Janet Valade -- janet.valade.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help in learning PHP and MySQL
Novice Learner wrote: I apologize if this is a very basic question. I just started learing PHP and MySQL, I am reading PHP and MySQL by Larry Ullman, I also have access to PHP 5 by Julie Meloni. I reached Chapter 6 of Ullman's book and got stuck. I have the following code: ?php //This file contains the database access information. This file also establishes a connection //to MYSQL and selects the database. //Set the database access information as constants define ('DB_USER', 'masud'); define ('DB_PASSWORD', 'masud'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'masud'); //Make the connection and then select the database $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); ? I have a normal MySQL user as masud, whose password is also masud and a database also called masud. All this for learning purpose. I get the following error message: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\CTA\mysql_connect.php on line 13 The books says: If you receive an error that claims mysql_connect() is an undefined function, it means that PHP has not been compiled with MySQL support. I have been running a test script with ? phpinfo(); ? and I get the results successfully. This is correct. In your phpinfo output, look for MySQL support. If you find no mention of mysql in the output, it means mysql support is not activated. PHP support was included by default in PHP 4, but is not in PHP 5. I am running Windows XP with Apache 2 server and PHP5 5.0.3 With PHP 5, you have to activate it yourself. MySQL support is no longer supported by default. There are two steps: 1) In your php.ini file, you need to uncomment the extension line for mysql. If you are using MySQL 4.0 or older, uncomment the line for php_mysql.dll. If you are using MySQL 4.1 or higher, uncomment the line for php_mysqli.dll 2) PHP needs to be able to find two files: php_mysql.dll (or php_mysqli.dll) and libmysql.dll. If you installed from the zip file, you have both. If you installed using the installer, you need to download the zip file which contains these files. Copy both files into your System32 directory. Janet I would appreciate if you could help me in any way, including pointing me to resources that can help get going. Thank you, Masud - Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. -- Janet Valade -- janet.valade.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] -14 Days Ago
Cole S. Ashcraft wrote: I am trying to see whether a data in an array pulled from a MySQL DB (YEARMONTHDATE) is older than 14 days ago. I am trying to do this in PHP. My code looks like: if($array['due'] = $today - 14) { echo h5Assignment In Void:/h5brh4Assignments in the void are read-only; require('footer.php'); exit; }. I am having problems with the math. How do I do a date subtraction without ending up with something like 20040994 (not a valid date)? Thanks, Cole You need dates in timestamp format to subtract them. You can use the function strtotime() to convert to timestamp. For instance, you can use: $old_date = strtotime(2 weeks ago); You then just need to convert the date from the database to a timestamp. strtotime will do something like: $db_date = strtotime(October 10 2004); or $db_date = strtotime(10 October 2004); But, I don't think it will do it your way. You may have to change the order of your string, as well as add spaces. Check the manual at http://us4.php.net/strtotime. IF the database value is in some kind of MySQL date format, you can perhaps retrieve it as a timestamp. MySQL has several DATE formats and date/time functions. Janet -- Janet Valade -- janet.valade.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] error
[EMAIL PROTECTED] wrote: Dear friends, Script writes to database, however gives this error while on internet web server, on local host doesn't give same error. Any guidance, please Thank you - Back to Main Notice: Undefined index: op in \\premfs15\sites\premium15\mrbushforpeace\webroot\replytopost.php on line 9 -- code of php script -- a href=www.abcdefg.usBack to Main/a ?php //connect to server and select database; we'll need it soon $conn = mysql_connect(orf-mysql1.brinkster.com, mrbushforpeace, poilkjmnb) or die(mysql_error()); mysql_select_db(mrbushforpeace,$conn) or die(mysql_error()); //check to see if we're showing the form or adding the post if ($_POST[op] != addpost) { // showing the form; check for required item in query string if (!$_GET[post_id]) { header(Location: topiclist.php); exit; } The problem reported in the error message is that PHP can't find the specified element in an array. I assume that line 9 is probably your if line above, with $_POST[op]. If so, the error means that PHP can't find the index op in $_POST. (You should be using single quotes here, e.g. $_POST['op']) This may or may not be a problem in your script. The reason you see the error message on one machine and not on another is probably because the two machines are set at different error reporting levels. Check the values for error_reporting in your php.ini file. The condition is the same on both machines, whether the notice is displayed or not. Whether or not the error is a problem depends on what your code is trying to do. You can eliminate the error message by checking whether the array element exists before using it (e.g., isset($_POST['op'])). Or you can just suppress the error message by putting a @ in front of the variable name. Janet -- Janet Valade -- janet.valade.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] empty query
In a message dated 1/25/2003 10:24:34 PM Pacific Standard Time, [EMAIL PROTECTED] writes: i have unsuccessfully tried for three days to write, re-write something that will insert data into my db and ashamedly have failed again. at one point i was able to echo values and see that they were in fact passing from my form. now i can't even get that. anyway, if you could take a look at this and tell me where i'm going wrong i will greatly appreciate it. thank you... addison ? session_start(); if (@$auth != yes) include(config.php); Is $auth a session variable? If so, is register_globals turned on? If not, you should probably be using $_SESSION['auth']. Janet -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql wildcard
In a message dated 1/8/03 2:48:15 PM Pacific Standard Time, [EMAIL PROTECTED] writes: I have an query: select * from offtime where type='$type' then I just pass the type variable to the page. Is there a wildcard in mysql like there is in sqlserver that I can use to grab all the records? such as select * from offtime where type='%' would grab all. Yes, MySQL has a wild card. It is % for a string of characters or _ for a single character. You can say things like where type like 'tp%'. However, if all you want to do is get all the records from a table, you can do that with: SELECT * FROM offtime Wild cards are used more for things like: SELECT * FROM offtime WHERE type LIKE 'tp%' You can also do pattern matching with regular expressions using REGEXP Janet -- Janet Valade author, PHP and MySQL for Dummies -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] a newbie in deep need for help
In a message dated 12/27/02 8:26:10 AM Pacific Standard Time, [EMAIL PROTECTED] writes: I am trying to retrieve a password and print it using a query which is written as followos $query2 = select passwd from user where username = '$username'; $result = mysql_result($query2); echo centerOld Password was $result /center; am I using mysql_result right or is there another function to print this password taking in consideration that it just prints Old Password was and Actually, it would go like this: $query2 = select passwd from user where username = '$username'; $result = mysql_query($query2); $row = mysql_fetch_array($result); extract($row); echo centerOld Password was $passwd /center; There are other ways. And shorter ones for this particular task. But this is kind of a general purpose set of statements that will usually do what you need. The mysql_query function sends the SQL query to the database and puts the data returned into a temporary table. mysql_fetch_array gets a row of data from the temporary table and puts it into an array that you can then process. The extract function creates separate variables from the array. If you are getting more than one row from the database, you can use the extract statement in a loop and process each row. Janet Janet Valade Author, PHP MySQL for Dummies -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting data from a page which isn't a form
If you have a form on your confirm page, with no text fields, just the submit button, you can use hidden fields in the form to pass the variables on. input type=hidden name=var1 value=$var1 --Janet - Original Message - From: Kim Kohen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, April 28, 2002 6:27 PM Subject: [PHP-DB] Getting data from a page which isn't a form Hi all, I'm using PHP to retrieve data from a form and pass it to a 'confirm' page. Here the data is echoed and the user presses a 'confirm' button to finally mail the information to us. This page is a basic html page (confirm.html) with some inline php which displays the relevant information. At the bottom there is a form 'confirm' button which has the action set to 'confirm.php' Confirm.php simply emails the data. The problem is that the variables are not getting passed to the confirm.php page - presumedly because they are not part of a valid form (confirm.html contains no form fields, just the 'confirm' button) I know the variables are all valid as I can echo them fine on the confirm.html page - I just don't know how to pass them onto the new page when they're not part of a form. Any assistance would be greatly appreciated. Cheers and thanks kim -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help needed - need to access a value from DB into all pages
Hi there, I am struggling with a concept and can't seem to find a way to do it so hoping you all can help. We want to use PHP with MySql Db. For security reasons on the DB, it is to be accessed only through this front end i.e. via the internal web Each user will have a number of levels of access to various parts of the system, so the obvious design is one where there is only 1 real login to the MySQL db (i.e. the system will auto log everyone in as this without them knowing it), and then the user is validated against a table in my DB which holds the access rights. I can get through the login OK, and get my table to return USERID for this person. Now I need that USERID available to ALL other pages so I can use it to determine what parts of screens to show, and what to allow them to do. My question is how do I make this variable available to all pages?? Do I have to include it with the variables passed to each page or is there a simpler way of doing it. Can I put the variable in an include file and include it in every page - will that work?. Surely someone must have had a similar situation before and can tell me how they solved it. Many thanks Janet -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ensuring unique field value in MySQL using PHP
I have a form in which users create their own login name. The code for storing the login name they created does something like the following: $userlogin is the name the user typed in the form $sql = select loginname from login where loginname='$userlogin'; $result=mysql_query($sql); $num=mysql_num_rows($result); if ($num 0) { echo Sorry, that login name is already taken, Try another; shows form again; } else insert new record into database; echo okay, your new account is added; I am wondering if it is possible that two people could hit the submit button at the exact same time with the same login name so that the same login name could get entered twice? Seems unlikely that this would happen by accident, but is this something a hacker could do on purpose? Thanks, Janet -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Unique Results?
$result = mysql_query(select distinct country from search); Janet - Original Message - From: Chris Payne [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 16, 2002 1:29 PM Subject: [PHP-DB] Unique Results? Hi there everyone, (Sorry if you got this twice, I don't think my mail server posted it earlier). I use the following code to populate a dropdown box from a MySQL database: $db = mysql_connect(localhost,^^^,^^^); mysql_select_db(mydb,$db); $result = mysql_query(select country from search); if ($result) { echo SELECT NAME='country'; while ($myrow = mysql_fetch_array($result)) { echo OPTION VALUE=\.$myrow[country].\. $myrow[country]. /OPTION ; } echo /SELECT; } However, this database has multiple country names the same (Aswell as unique ones) how can I display just ONE of each entry? IE: say there are 5 africa, 3 britain etc . I only want the list to show 1 of each and not 5 and 3 and so on - how is this possible? Please help :-) And thank you to everyone who helped me with an earlier enquiry, it's very appreciated :-) Chris Payne www.planetoxygene.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]