phplearner2008
Members-
Posts
34 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
phplearner2008's Achievements
Member (2/5)
0
Reputation
-
[SOLVED] problem in creating foreign key
phplearner2008 replied to phplearner2008's topic in MySQL Help
Thanks Daniel. It works now! -
Hi, I am a mysql newbie. I have two tables profile and interest for which i want to create foreign key relationship. profile table has following fields ( id int(10) not null primary key email varchar(30) not null unique key password varchar(20) not null name varchar(20) ) interest table has following fields ( sent_by int(10) not null primary key sent_to int(10) not null primary key status varchar(10) not null ) I tried to create foreign key relationship like this ALTER TABLE interest ADD FOREIGN KEY(sent_by,sent_to) REFERENCES profile(id) ON DELETE CASCADE ON UPDATE CASCADE But I got error code: 1005 Cannot create table'\.#sql778_1.frm'(errno.150) The profile table has only one primary key that is 'id'. The interest table has combination of columns sent_by and sent_to as primary keys. How do i create foreign key relationship. Can anyone guide me? Thanks
-
[SOLVED] how to redirect page after include
phplearner2008 replied to phplearner2008's topic in PHP Coding Help
I used <meta http-equiv="refresh" content="0;URL=Interests_Sent.php"> instead of header and my problem is solved. Thanks for your help! -
Hi, I have a file Interest_Sent.php where there is a checkbox and delete button, When the checkbox is checked and delete is pressed, it goes to process.php. I am posting the code below: <?php include_once('C:\Program Files\Apache Group\Apache2\htdocs\matrimonial\config.php'); $MY_ID = $_POST['MY_ID']; if(isset($_SERVER['HTTP_REFERER'])) $ref = $_SERVER['HTTP_REFERER']; if($ref == 'http://localhost/matrimonial/templates/Interests_Sent.php') { $checkbox = array(); $checkbox = $_POST['box']; $count = count($checkbox); for($i=0;$i<$count;$i++) { $value = $checkbox[$i]; $sql = "UPDATE interests_sent SET DELETED = 'Yes', DELETED_DATE = CURDATE() WHERE MY_ID = '$MY_ID' AND INTEREST_SENT = '$value' AND DELETED = 'No'"; $result = mysql_query($sql); if($result) { ob_start(); //start buffer include('C:\Program Files\Apache Group\Apache2\htdocs\matrimonial\Interests_Sent.php'); //we pass the output of include file to a variable $buffer = ob_get_contents(); ob_end_clean(); header("Location:http://localhost/matrimonial/templates/Interests_Sent.php"); } else echo "Could not delete"; } } ?> The above code works fine except for last but one line(header line). How do I redirect my page to Interests_Sent.php after these operations at process.php is completed? In other words how can I redirect a page after using include without getting "Headers already sent" error? Thanks.
-
how to prevent direct access of web page by typing url
phplearner2008 replied to phplearner2008's topic in PHP Coding Help
btherl, can you expand on your second suggestion using sessions? -
how to run mysql queries in succession
phplearner2008 replied to phplearner2008's topic in PHP Coding Help
The die statement which you are referring to is for my debugging purpose(to know the type of error caused) I will remove it when everything works fine. Please ignore it. I plan to ignore temp table, but still I have to insert data to profile table and profile_contact table. How can I make sure that both the queries take place in succession and another user does not insert data between these two queries. -
Dear all, I am trying to insert data to two tables in mysql, first in temp table and then in profile table through php.It works fine but sometimes I get a "maximum execution time of 30 seconds exceeded error". When I checked the database I found that data had been inserted into temp table but error had occurred before data was inserted into profile table. I want both the mysql queries to run in succession before another user tries to insert data. I also want a kind of rollback that is if data is inserted into temp and error occurs before inserting to profile, I want data to be deleted from temp table too. My code is as follows. Any help would be appreciated. <?php session_start(); set_time_limit(120); include('C:\Program Files\Apache Group\Apache2\htdocs\matrimonial\config.php'); $NAME = $_SESSION['NAME']; $AGE = $_SESSION['AGE']; $DOB_MONTH = $_SESSION['DOB_MONTH']; $DOB_DATE = $_SESSION['DOB_DATE']; $DOB_YEAR = $_SESSION['DOB_YEAR']; $GENDER = $_SESSION['GENDER']; mysql_select_db($dbname,$con); $sql = "INSERT INTO temp(NAME,AGE,DOB_MONTH,DOB_DATE,DOB_YEAR,GENDER) VALUES('$NAME','$AGE','$DOB_MONTH','$DOB_DATE','$DOB_YEAR', '$GENDER')"; if(!mysql_query($sql,$con)) { die("Query: " . $sql . "\n\n" . mysql_error()); header('Location: http://localhost/matrimonial/Templates/RegistrationFailed.htm'); } else { $q = "INSERT INTO profile(NAME,AGE,DOB_MONTH,DOB_DATE,DOB_YEAR,GENDER) VALUES('$NAME','$AGE','$DOB_MONTH','$DOB_DATE','$DOB_YEAR', '$GENDER')"; $qresult = mysql_query($q) or die("Query: " . $q . "\n\n" . mysql_error());; if($qresult) { $query = "SELECT * FROM profile ORDER BY MATRIMONIAL_ID DESC LIMIT 1"; $queryresult = mysql_query($query) or die("Query: " . $query . "\n\n" . mysql_error()); $row = mysql_fetch_array($queryresult); $MATRIMONIAL_ID = $row['MATRIMONIAL_ID']; $MYLOGIN = $row['MATRIMONIAL_ID']; $NAME = $row['NAME']; $QUESTION = $row['QUESTION']; $ANSWER = $row['ANSWER']; $EMAIL = $row['EMAIL']; $sql1 = "INSERT INTO profile_contact(MATRIMONIAL_ID,CONTACT_ADDRESS,COUNTRY_CODE,AREA_CODE,CONTACT_PHONE,CONTACT_MOBILE) VALUES('$MATRIMONIAL_ID','$CONTACT_ADDRESS','$COUNTRY_CODE','$AREA_CODE','$CONTACT_PHONE','$CONTACT_MOBILE')"; $result = mysql_query($sql1) or die("Query: " . $sql1 . "\n\n" . mysql_error()); if($result) { $_SESSION['MATRIMONIAL_ID'] = $MATRIMONIAL_ID; $_SESSION['MYLOGIN'] = $MYLOGIN; $_SESSION['NAME'] = $NAME; $_SESSION['QUESTION'] = $QUESTION; $_SESSION['ANSWER'] = $ANSWER; $_SESSION['EMAIL'] = $EMAIL; header('Location: http://localhost/matrimonial/Templates/RegistrationSuccessful.php'); } else { header('Location: http://localhost/matrimonial/Templates/RegistrationFailed.php'); } } else header('Location: http://localhost/matrimonial/Templates/RegistrationFailed.php'); } mysql_close($con); ?>
-
Here's my code for file upload: <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="uploadPhoto.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td><strong>Single File Upload </strong></td> </tr> <tr> <td>Select file <input name="file_up" type="file" id="file_up" size="50" /></td> </tr> <tr> <td align="center"><input type="submit" name="Submit" value="Upload" /></td> </tr> </table> </td> </form> </tr> </table> Below is the code which does the file upload "uploadPhoto.php" <? $file_upload="true"; $file_up_size=$_FILES['file_up']; echo $_FILES[file_up][name]; if ($_FILES[file_up]>250000){$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload. Visit the help page to know how to reduce the file size.<BR>"; $file_upload="false";} if (!($_FILES[file_up][type] =="image/jpeg" OR $_FILES[file_up][type] =="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>"; $file_upload="false";} $file_name=$_FILES[file_up][name]; $add="upload/$file_name"; // the path with the file name where the file will be stored, upload is the directory name. if($file_upload=="true"){ if(move_uploaded_file ($_FILES[file_up][tmp_name], $add)) { echo "File uploaded"; }else{echo "Failed to upload file Contact Site admin to fix the problem";} }else{echo $msg;} ?> Any suggestions?
-
Dear all, Anyone who can help me out with the above query?
-
Hi all, I have a php script for uploading files. But when i try to upload I am getting a message function.copy: failed to open stream: HTTP wrapper does not support writeable connections in uploadPhoto.php what should I do to make it work?
-
Dear all, I have a php script for uploading a file. But when I tried to upload, I am getting a warning : function.copy failed to open stream: HTTP wrapper does not support writeable conditions in uploadPhoto.php. I have Windows XP / Apache / MySQL combination. I understand that I should give permission to the directory where the uploaded files are to be stored. Can anyone tell me in steps how I can change permissions in apache/Windows XP combination. Thank you.
-
I am sorry if this is not the proper forum, still I post this I created a template page in dreamweaver and applied timelines with three images looping around. It works absolutely fine in the browser. I created a new php page applying the template I created. But the browser displays only the first image(gif) and not other two images. Can anyone tell me why is this? Thanks
-
[SOLVED] how to send variable through link
phplearner2008 replied to phplearner2008's topic in PHP Coding Help
Thank you ranjuvs, I made a small change to your code and it worked! Instead of <a href = "http://localhost/mypage.php?id="<?php print $id ?>>MyPage</a> I put ending quotes at end of php like this <a href = "http://localhost/mypage.php?id=<?php print $id ?>">MyPage</a> My problem is solved -
[SOLVED] how to send variable through link
phplearner2008 replied to phplearner2008's topic in PHP Coding Help
<?php while($row = mysql_fetch_array($result)) { $id = $row['name']; } ?> <a href="http://localhost/mypage.php?id=$id">Mypage</a> In mypage.php, $myid = $_GET['id']; echo "$myid"; This is the code I am trying to execute. Any suggestions?