Re: [PHP-DB] MySQL Foreign Key Issue
Luchino - Samel wrote: *Question No. 01* there are some kind of foreign key in database Some of them want give any error when you delete from the table where the foreign key is in, this cause the remove is recursive and it delete also the ORDER linked to the CUSTOMER (CASCADE foreign key). In other kind of foreign key (I don't remember the name) you cannot delete CUSTOMER if there is some ORDER linked to them. restrict hope this will help c-ya 2007/3/26, Lasitha Alawatta [EMAIL PROTECTED]: Hello, I have 2 issue, regarding MySQL Foreign Key. I have two tables; Table 01 *CUSTOMER* column name characteristic SID Primary Key Full_Name Table *ORDERS* column name characteristic Order_ID Primary Key Order_Date Customer_SID Foreign Key Amount When I run ALTER TABLE ORDERS ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID); that sql statement, I inserted 2 records to both tables. * * *Question No. 01.* Then I removed 1 record from CUSTOMER table. But It want give any error message. It should give an error message, because in ORDERS table already have some records relevant to the deleted customer record in CUSTOMER table. you have restrict constraint on Customer_SID in table orders. You have 2 options: 1. delete from orders where Customer_SID=foo delete from customer where SID=foo 2. read http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] sunrise / sunsite / correcting for summer time
On Sun, 25 Mar 2007 23:15:21 +0100, Niel Archer [EMAIL PROTECTED] wrote: Hi, see the docs for the date() function. 'I' returns 0 or 1 indicating Daylight Saving Time. However, it does this based on the settings for your installation. i.e. if your webserver is running on a host configured to U.S. time zone, it'll give U.S. DST results. Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] problems with functions/included files/mysql resource
Hello Everyone, I am new to this or any news group. The end of this story is that I believe I am calling a function from within a function in a way that I should not be, but I cannot figure out exactly what part I am doing incorrectly. I have the following main file with other content included from outside files (summarized): ?php //main_file.php //the following defines functions to connect to the data base and submit queries require('databasefunctions.php'); / /the following defines a function that uses above database functions to build a dropdown list from database tables require('dropdownlistfunctions.php'); //some if/then statements //... //... //the following builds a form that is displayed. It uses a function from dropdownlistfunctions.php (above) to build a dropdown list. require('build_form.php'); ? When I use the functions from databasefunctions.php directly in the main_file.php to connect to a database and run a query, the functions work successfully. However, when I use those functions from within a function defined inside the dropdownlistfunctions.php, I get an error Undefined variable: [variable name]. The [variable name] is supposed to contain the mysql-link resource. Since it isn't there, I also get additional warnings that the mysql_query didn't receive a valid mysql-link resource. In the function to connect to and select the database, I make the mysql-link resource a global value. Inside the dropdownlistfunctions.php, when I simply write the statements directly in the function to connect to and select the database, and run the query, that works too. Is there a basic rule about including/requiring files, and using functions within functions that I am not abiding by? It feels as though I am just trying to do some particular thing that you can't do when working with functions that use other functions ... and maybe to do with including/requiring files as well. Any wisdom would be eagerly and gratefully consumed. Kindest regards, JH -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Using apostrophe's within a text field
OK guys, here is my delima, which is probably very easy to solve, but I can't seem to find it. I am trying to get form fields to accept apostrophes within the input and stop crashing on me. I'm writing forms into a mysql database and everything works great unless the user enters a word like won't or can't. Them it crashes during the form submit. What can I do to fix this stupid thing anyway? thanks in advance. Steve Smith
Re: [PHP-DB] problems with functions/included files/mysql resource
Hi, In the function to connect to and select the database, I make the mysql-link resource a global value. It sounds like you've misunderstood 'global' variable. The global statement needs to go inside the function where you want to use the variable, not where you assign it. This tells that function to access that variable from the global scope. You will need to have this variable available at the global scope. Creating it inside another function will not do, you must return that from the function to the global scope too e.g. ?php $db = new mysql; ... some code ... function UseDb() { global $db; ... some more code ... } ? Niel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] problems with functions/included files/mysql resource
In the function to connect to and select the database, I make the mysql-link resource a global value. How are you doing that? Code please :) Obviously change the password etc.. And how are you referencing it in the other files/functions? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Using apostrophe's within a text field
Stephen Smith wrote: OK guys, here is my delima, which is probably very easy to solve, but I can't seem to find it. I am trying to get form fields to accept apostrophes within the input and stop crashing on me. I'm writing forms into a mysql database and everything works great unless the user enters a word like won't or can't. Them it crashes during the form submit. What can I do to fix this stupid thing anyway? Are you having issues displaying the data or saving it to a database? If it's going into a database, use the appropriate escape_string function. Eg mysql_real_escape_string (php.net/mysql_real_escape_string) or pg_escape_string (php.net/pg_escape_string) or as a last resort addslashes (php.net/addslashes) When you display the data back, use htmlspecialchars or htmlentities. Read http://phpsec.org/projects/guide/3.html for more info. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] echo
Hi all, I am new to web programming. I have code to add pictures to a MYSQL database. Now I can't seem to figure out how to get them back out ! so we can see them. The MySQL doesn't seem to be a problem (yet), also I'm trying to learn PHP. What I usually do is to load the images in a folder img and then the name of the pic (i.e. myphoto.jpg) in the database, so i retrieve the name of the pic with: Code: ?php $connex = MySQL_connect(server,login,password); $sql_query = select picname from photos where...; $result = MySQL_query($sql_query,$connex); $row = MySQL_fetch_array($result); ? and then: Code: echo img src=.$row['photoFileName']. alt='photo'; but I can't see the photo Any pointers or code samples will be greatly appreciated... - Bored stiff? Loosen up... Download and play hundreds of games for free on Yahoo! Games.
Re: [PHP-DB] echo
You might be missing a quote so here and there unless you have the quotes stored in the database too. Since your photos are stored on disk, make sure the webserver has access to them. Then make sure that your string is something like img src=pathphotoFileName in php: printf(img src=\%s%s\, $somepath, $somefilename); in your php line: echo img src=.$row['photoFileName']. alt='photo'; the line echoed doesn't have any quotes in it. Ron elk dolk wrote: Hi all, I am new to web programming. I have code to add pictures to a MYSQL database. Now I can't seem to figure out how to get them back out ! so we can see them. The MySQL doesn't seem to be a problem (yet), also I'm trying to learn PHP. What I usually do is to load the images in a folder img and then the name of the pic (i.e. myphoto.jpg) in the database, so i retrieve the name of the pic with: Code: ?php $connex = MySQL_connect(server,login,password); $sql_query = select picname from photos where...; $result = MySQL_query($sql_query,$connex); $row = MySQL_fetch_array($result); ? and then: Code: echo img src=.$row['photoFileName']. alt='photo'; but I can't see the photo Any pointers or code samples will be greatly appreciated... - Bored stiff? Loosen up... Download and play hundreds of games for free on Yahoo! Games. -- = It's is not, it isn't ain't, and it's it's, not its, if you mean it is. If you don't, it's its. Then too, it's hers. It isn't her's. It isn't our's either. It's ours, and likewise yours and theirs. -- Oxford Uni Press = Ron Croonenberg | | Phone: 1 765 658 4761 Lab Instructor | Fax: 1 765 658 4732 Technology Coordinator| | Department of Computer Science| e-mail: [EMAIL PROTECTED] DePauw University | 275 Julian Science Math Center | 602 South College Ave.| Greencastle, IN 46135| = http://www.csc.depauw.edu/RonCroonenberg.html = -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Using apostrophe's within a text field
There is that mysql function that is meant for prevention of sql injection when a single quote or so is entered sql starts acting up. because the sql syntax is not correct anymore. then your sql functions start acting up and you get to see all those informative msgs Turning a ' into a '' or a into a works too, but the mysql function for that works better safer etc. Ron Stephen Smith wrote: OK guys, here is my delima, which is probably very easy to solve, but I can't seem to find it. I am trying to get form fields to accept apostrophes within the input and stop crashing on me. I'm writing forms into a mysql database and everything works great unless the user enters a word like won't or can't. Them it crashes during the form submit. What can I do to fix this stupid thing anyway? thanks in advance. Steve Smith -- = It's is not, it isn't ain't, and it's it's, not its, if you mean it is. If you don't, it's its. Then too, it's hers. It isn't her's. It isn't our's either. It's ours, and likewise yours and theirs. -- Oxford Uni Press = Ron Croonenberg | | Phone: 1 765 658 4761 Lab Instructor | Fax: 1 765 658 4732 Technology Coordinator| | Department of Computer Science| e-mail: [EMAIL PROTECTED] DePauw University | 275 Julian Science Math Center | 602 South College Ave.| Greencastle, IN 46135| = http://www.csc.depauw.edu/RonCroonenberg.html = -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] echo
elk dolk wrote: Hi all, I am new to web programming. I have code to add pictures to a MYSQL database. Now I can't seem to figure out how to get them back out ! so we can see them. The MySQL doesn't seem to be a problem (yet), also I'm trying to learn PHP. What I usually do is to load the images in a folder img and then the name of the pic (i.e. myphoto.jpg) in the database, so i retrieve the name of the pic with: Code: ?php $connex = MySQL_connect(server,login,password); $sql_query = select picname from photos where...; $result = MySQL_query($sql_query,$connex); $row = MySQL_fetch_array($result); ? and then: Code: echo img src=.$row['photoFileName']. alt='photo'; but I can't see the photo Any pointers or code samples will be greatly appreciated... Are you storing the whole file in the database or just the path to the file? If you're storing just the path, then your script is pointing to the wrong directory and/or the file it's trying to reference doesn't exist (or a permissions issue maybe). If you're storing the whole file you need a new php script to pull it back out. Then in your html code you do: echo 'img src=/path/to/display_image.php?image_id=' . $row['imageid'] . ''; That will hit 'display_image.php' and pull the image contents out of the database. See http://www.phpriot.com/d/articles/database/images-in-mysql/page8.html for an example. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] echo
I am storing just the name of photos in the database and the photos are in /img folder , and there is no permissions issue. My testing server is IIS And the path would be something like this : Inetpub\wwwroot\album\img as I am running out of time! could someone complete this code just with one echo and img src so that I can retrive my photos ? MySQL columns : photoID=seq number photoFileName=name of my photo like 3sw.jpg title=title description=short description ?php $link = mysql_connect('localhost', 'root', 'pw'); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('album', $link); $query = SELECT * FROM photo; $result=mysql_query($query); while ($row = mysql_fetch_array($result)) { echo??? } mysql_free_result($result); ? - Expecting? Get great news right away with email Auto-Check. Try the Yahoo! Mail Beta.
[PHP-DB] Re: Using apostrophe's within a text field
Stephen Smith wrote: OK guys, here is my delima, which is probably very easy to solve, but I can't seem to find it. I am trying to get form fields to accept apostrophes within the input and stop crashing on me. I'm writing forms into a mysql database and everything works great unless the user enters a word like won't or can't. Them it crashes during the form submit. What can I do to fix this stupid thing anyway? thanks in advance. Steve Smith http://php.net/mysql_real_escape_string The manual is your friend. Cheers -- David Robley I'm Serfectly Pober. Today is Boomtime, the 14th day of Discord in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] echo
elk dolk wrote: I am storing just the name of photos in the database and the photos are in /img folder , and there is no permissions issue. So it's a path issue. You need to reference the image as: img src=/img/image_name_here -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php