PHP - Delete Info From Two Tables
I'm wanting to delete information that is located in two different tables.
It will delete from one table (`orgs`) but not from the other (`users`). So, the issue is somewhere with $result1. Any help would be appreciated! Thanks in advance! function delmilitia() { if (isset($_POST['delete'])) { $id = $_POST['id']; $peep = ucwords(strtolower($action3[1])); $dbh=dbconnect() or die ('GetUser error: ' . mysql_error()."<br>"); mysql_select_db("katarra_live"); $result = mysql_query("delete FROM `orgs` WHERE id=$id"); $result1 = mysql_query("delete FROM `users` WHERE militia=$id"); } if (isset($_POST['clear'])) { $dbh=dbconnect() or die ('GetUser error: ' . mysql_error()."<br>"); mysql_select_db("katarra_live"); $result = mysql_query("delete FROM `orgs` WHERE id=$id"); $result1 = mysql_query("delete FROM `users` WHERE militia=$id"); } $page = "<b><u>Delete Militia</b></u><br /><br />Click the Delete button next to the appropriate entry to remove that entry from the database."; $delquery = doquery("SELECT * FROM `orgs` ORDER BY name", "orgs"); while ($delrow = mysql_fetch_array($delquery)) { if ($bg == 1) { $page .= "<div style=\"width:98%; background-color:#eeeeee; font-family: tahoma; font-size: 8pt; line-height: 1.4em; color: #0A3549;\"><form action=\"admin_panel.php?do=delmilitia\" method=\"post\"><p><input type=\"submit\" value=\"Delete\" name=\"delete\"> <input type=\"hidden\" name=\"id\" value=\"".$delrow["id"]."\"><b>".$delrow["name"]."</b></p></form></div>\n"; $bg = 2; } else { $page .= "<div style=\"width:98%; background-color:#ffffff; font-family: tahoma; font-size: 8pt; line-height: 1.4em; color: #0A3549;\"><form action=\"admin_panel.php?do=delmilitia\" method=\"post\"><p><input type=\"submit\" value=\"Delete\" name=\"delete\"> <input type=\"hidden\" name=\"id\" value=\"".$delrow["id"]."\"><b>".$delrow["name"]."</b></p></form></div>\n"; $bg = 1; } } admindisplay($page, "Delete Militia"); } Similar TutorialsHi All, I am adding a button that will delete many things in the system which all have the same $job_id There is going to be 10 or so tables that need to delete * where $job_id = ? Is there a better way to do this rather than just iterating my code 10 times. I was looking at just joining but isnt one benefit of prepared statements that they can be used again and again to increase speed. I am working on a project where I want a select form to display information from a MySQL table. The select values will be different sports (basketball,baseball,hockey,football) and the display will be various players from those sports. I have set up so far two tables in MySQL. One is called 'sports' and contains two columns. Once called 'category_id' and that is the primary key and auto increments. The other column is 'sports' and contains the various sports I mentioned. For my select menu I created the following code. <?php #connect to MySQL $conn = @mysql_connect( "localhost","uname","pw") or die( "You did not successfully connect to the DB!" ); #select the specified database $rs = @mysql_SELECT_DB ("test", $conn ) or die ( "Error connecting to the database test!"); ?> <html> <head>Display MySQL</head> <body> <form name="form2" id="form2"action="" > <select name="categoryID"> <?php $sql = "SELECT category_id, sport FROM sports ". "ORDER BY sport"; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['category_id']."\">".$row['sport']."</option>\n "; } ?> </select> </form> </body> </html> this works great. I also created another table called 'players' which contains the fields 'player_id' which is the primary key and auto increments, category_id' which is the foreign key for the sports table, sport, first_name, last_name. The code I am using the query and display the desired result is as follows <html> <head> <title>Get MySQL Data</title> </head> <body> <?php #connect to MySQL $conn = @mysql_connect( "localhost","uname","pw") or die( "Err:Db" ); #select the specified database $rs = @mysql_SELECT_DB ("test", $conn ) or die ( "Err:Db"); #create the query $sql ="SELECT * FROM sports INNER JOIN players ON sports.category_id = players.category_id WHERE players.sport = 'Basketball'"; #execute the query $rs = mysql_query($sql,$conn); #write the data while( $row = mysql_fetch_array( $rs) ) { echo ("<table border='1'><tr><td>"); echo ("Caetegory ID: " . $row["category_id"] ); echo ("</td>"); echo ("<td>"); echo ( "Sport: " .$row["sport"]); echo ("</td>"); echo ("<td>"); echo ( "first_name: " .$row["first_name"]); echo ("</td>"); echo ("<td>"); echo ( "last_name: " .$row["last_name"]); echo ("</td>"); echo ("</tr></table>"); } ?> </body> </html> this also works fine. All I need to do is tie the two together so that when a particular sport is selected, the query will display below in a table. I know I need to change my WHERE clause to a variable. This is what I need help with. thanks Heres what i got... function printLB1 (){ $result = mysql_query("SELECT * FROM leaderboards ORDER BY CollegeFootballPoints DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->Username; $leaderboardPoints[] = $row->CollegeFootballPoints; } $num = mysql_num_rows($reault); //I know from here to ................... needs to be in a var or echo or something. <tr> <td>1.</td> //This will auto increment too like i++ but i cna do that myself! <td>echo $leaderboard;</td> <td>echo $leaderboardPoints;</td> </tr> //Here......................................................... } I need to pull a table row per user. But i want to somehow do it once in a function and then ill echo the function into a table after the php stuff is done. Like i want to pull every a table row per user in the function. then display the function below that way i don't have to write a whole extra query and table row per person. If you understand please help if not please let me know where i can explain more. Thanks Hi all. Here is my scripts which allow user to check multiple rows of data and delete it , but it require select data and click for twice to delete the rows , what should be the error? Code: [Select] <form name="frmSearch" method="post" action="insert-add.php"> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> </form> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if (isset($_POST['delete']) && isset($_POST['checkbox'])) // from button name="delete" { $checkbox = ($_POST['checkbox']); //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql) or trigger_error(mysql_error());;; } if($result2) { $fgmembersite->GetSelfScript(); } else { echo "Error: ".mysql_error(); } } echo "</form>"; Thanks for every reply. <body> <?php include 'sql.php'; $query = "SELECT * FROM validation"; $result = mysqli_query($con , $query); $rows = mysqli_fetch_assoc($result) ; $totals = mysqli_num_rows($result) ; ?> <div id="css"> <form > <table width="80%" border="0" cellpadding="2" cellspacing="2" > <caption><h2>Personal Details of Customers</h2></caption> <tr class="white"> <td bgcolor="#330033"> </td> <td bgcolor="#330033"> Id Number </td> <td bgcolor="#330033"> Full Name </td> <td bgcolor="#330033"> Email Address </td> <td bgcolor="#330033"> Website </td> <td bgcolor="#330033"> Comment </td> <td bgcolor="#330033"> Time </td> </tr> <?php while($rows=mysqli_fetch_assoc($result) { <tr> <input type="raido" name="ID" value="<?php echo $rows['ID']; ?>" /> <td bgcolor="#FFFFCC"><?php echo $rows['ID'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Name'];?> </td> <td bgcolor="#FFFFCC"><?php echo $rows['Email'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Website'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Comment'];?></td> <td bgcolor="#FFFFCC"><?php echo $rows['Time'];?></td> <td> </td> <td> <a href="delete.php? ID= "$rows[ID]" /"> <input type="submit" name="del" value="Delete" /> </a> <input type="button" name= "edit" value="Edit" /> </td> </tr> }?> </table> </form> </div> </body> Hi,
I wish to find out is there any possible that I can delete some data inside my php website but inside my sql database, the record will still at there?
Thank you.
I'm trying to set it so that it will delete an entire populated directory based upon a value in the database then after finishing that to go back and delete that row in the database. my current code is Code: [Select] <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="delprod.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product To Remove:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select name=\"which\">"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['id'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> and the delete script Code: [Select] <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT id FROM Products WHERE id=$_POST['which']"); $row = mysql_fetch_array($result) chdir('assets'); chdir('images'); $mydir = $row . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($_POST['which'] . '/' . $entry); } } rmdir($mydir); $result = mysql_query("DELETE * FROM Producs WHERE id=$_POST['which']"); ?> Thank you in advance for all your help. any easier ways of approaching this will be welcome as well Im doing a search system and Im having some problems.
I need to search in two tables (news and pages), I already had sucess doing my search system for just one table, but for two tables its not easy to do.
I already use a select statment with two tables using UNION because I want to show number of search results, that is number of returned rows of my first sql statment.
But now I need to do a select statment that allows me to acess all fields of my news table and all fields of my pages table.
I need to acess in my news table this fields: id, title, content, link, date, nViews
I need to acess in my pages table this fields: id, title, content, link
Im trying to do this also with UNION, but in this case Im not having any row returning.
Do you see what I have wrong in my code?
<?php //first I get my $search keyword $search = $url[1]; $pdo = connecting(); //then I want to show number of returned rows for keyword searched $readALL = $pdo->prepare("SELECT title,content FROM news WHERE title LIKE ? OR content LIKE ? UNION SELECT title,content FROM pages WHERE title LIKE ? OR content like ?"); $readALL->bindValue(1,"%$search%", PDO::PARAM_STR); $readALL->bindValue(2,"%$search%", PDO::PARAM_STR); $readALL->bindValue(3,"%$search%", PDO::PARAM_STR); $readALL->bindValue(4,"%$search%", PDO::PARAM_STR); $readALL->execute(); //I show number of returned rows echo '<p>Your search keyword returned <strong>'.$readALL->rowCount().'</strong> results!</p>'; //If dont return any rows I show a error message if($readALL->rowCount() <=0){ echo 'Sorry but we didnt found any result for your keyword search.'; } else{ //If return rows I want to show, if it is a page result I want to show title and link that I have in my page table //if it is a news result I want to show title and link that I have in my news table and also date of news echo '<ul class="searchlist">'; $readALL2 = $pdo->prepare("SELECT * FROM news WHERE status = ? AND title LIKE ? OR content LIKE ? LIMIT 0,4 UNION SELECT * FROM pages where title LIKE ? OR content LIKE ? LIMIT 0,4"); $readALL2->bindValue(1, '1'); $readALL2->bindValue(2, "%$search%", PDO::PARAM_STR); $readALL2->bindValue(3, "%$search%", PDO::PARAM_STR); $readALL2->bindValue(4, "%$search%", PDO::PARAM_STR); $readALL2->execute(); while ($result = $readALL2->fetch(PDO::FETCH_ASSOC)){ echo '<li>'; echo '<img src="'.BASE.'/uploads/news/'.$result['thumb'].'"/>'; echo '<a href="'.BASE.'/news/'.$result['id_news'].'">'.$result['title'].'</a>'; //if it is a news result I also want to show date on my list //echo '<span id="date">'.$result['date'].'</span>'; echo '</li>'; } echo ' </ul>'; //but how can I do my select statement to have access to my news table fields and my page table fields?? } ?> This portion is kind of stumping me. Basically, I have a two tables in this DB: users and users_access_level (Separated for DB normalization) users: id / username / password / realname / access_level users_access_level: access_level / access_name What I'm trying to do, is echo the data onto an HTML table that displays users.username in one table data and then uses the users.access_level to find users_access_level.access_name and echo into the following table data, I would prefer not to use multiple queries if possible or nested queries. Example row for users: 1234 / tmac / password / tmac / 99 Example row for users_access_level: 99 / Admin Using the examples above, I would want the output to appear as such: Username: Access Name: Tmac Admin I am not 100% sure where to start with this, but I pick up quickly, I just need a nudge in the right direction. The code I attempted to create just shows my lack of knowledge of joining tables, but I'll post it if you want to see that I did at least make an effort to code this myself. Thanks for reading! I am trying to write some data from multiple SQL tables to a page. In the first table is a list of places. I then have more tables that are named after the different places. For example, say my first place in the list is called Place1. I have a table named Place1 with data that corresponds to place1. The data contained in the table named Place1 is a list of things to do in this place. It has 21 columns and each one is something to do in the morning, afternoon, and at night for each day of the week in the place Place1. What I am trying to do is display a sort of weekly calendar as a table on a webpage that lists all of the places in one column and then lists seven days of the week as 7 more columns. Then in each data cell I would want to list the things to do in the morning, afternoon and at night for the certain day of the week and for the place. The problem is that I am creating a CMS to allow other users with no coding knowledge to update events for other places, so I have to display data that could have been altered. The only solution I know of is to do a while loop that gets all of the place names and while there are still place names, write the place names to the page and set a variable equal to the place name. Inside the while loop I would create another while loop that each time the first while loop is executed uses the variable set in the first while loop to know which table to reference and then make a call to that table pulling out the 21 columns and writing them to the page. Each time the outer while loop executes, it would (hopefully) write the place name, and then set the variable as the current place name so that the inner while loop uses the variable to write the rest of the information about that place. I don't know if that would even work and if it did, I know it cannot be the best way to do this. I am pretty stuck here and don't really have a good solution so if anyone proposes a solution that is radically different to anything I have done, I am open to everything. Thank you! Hey guys, It's been awhile since I've coded in PHP and I can not for the life of me remember how to do this. Say I have http://www.example.com/search.php?name=joe&size=small What the PHP code to grab the ?name=joe&size=small part? thanks Very simple question. I have a table with courses and a table with students registered for those courses. I have a page where I can change the course name. What I want to do is, when changing the course name in the course table, I want all students in the students table who are already registered for that course to have that course name updated as well in the student table. I'm currently using a field cid to update the courses in the course table however, the student table doesn't have a cid field rather a cname ( course name) which I want to use to update the fields in the student table. Is it possible to use Code: [Select] <a href=\"editcourse.php?cid=" for more than one field of info? i.e transfer the cid + cname and so you can use $_GET[cid]"; and $_GET[cname]"; ? Something like this maybe ( dont know how the code will go) "editcourse.php?cid=&cname=" ? Do I have the right idea for how to go about this? ok im back quicker than i thought.... i got my drop box sorted and i got it reloading the page. so it all works correctly. but how do i get the page to display information regarding the film i have selected in the drop box.? i have no code for this at the mo. also i would like the drop box to display the selected item at top of box when it refreshes code for drop box: Code: [Select] <FORM> <?php $result = mysql_query( "SELECT * FROM movie_info ORDER BY title ASC ") ; echo "<select name= Film onChange='submit()' >film name</option>"; while ($nt=mysql_fetch_array($result)){ ?> <?php echo "<option value='$nt[id]'>$nt[title] </option>"; } ?> </select> </FORM> any help would be great Hi Experts, How can I check whether I have FSOCKOPEN support from phpinfo() page? Thanks, In my script, users login with their Username & Password. However, I'd like to be able to echo the email address used on their account.
I've tried adding the email to the session I'm not having much luck... Here's a piece of the login code(untouched); $username = $_POST['name']; $passwd = $_POST['passwd']; $query = "SELECT name,passwd FROM users WHERE CONCAT('0x', hex(passwd)) = '{$salt}'"; $result = mysql_query($query); $login_ok = false; if(mysql_num_rows($result) > 0) { $login_ok = true; } if($login_ok) { $row = mysql_fetch_array($result, MYSQL_NUM); $_SESSION['user'] = $row;I've also tried messing around with this piece below in a few different ways but still nothing. <?php echo htmlentities($_SESSION['user']['email'], ENT_QUOTES, 'UTF-8'); ?>Any help is greatly appreciated.. I am parsing an rss feed from my flickr photostream using this:-
<?php $url = "http://api.flickr.com/services/feeds/photos_public.gne?id=49466419@N05&lang=en-us&format=rss_200"; $rss = simplexml_load_file($url); if($rss) { echo '<h1>'.$rss->channel->title.'</h1>'; echo '<li>'.$rss->channel->pubDate.'</li>'; $items = $rss->channel->item; foreach($items as $item) { $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; echo '<h3><a href="'.$link.'">'.$title.'</a></h3>'; echo '<span>('.$published_on.')</span>'; echo '<p>'.$description.'</p>'; } } ?>which gives me this as the description for each image:- public 'description' => string ' <p><a href="http://www.flickr.com/people/alfthomas/">Alf Thomas</a> posted a photo:</p> <p><a href="http://www.flickr.com/photos/alfthomas/14064465890/" title="harlaw_12"> <img src="http://farm6.staticflickr.com/5077/14064465890_83c02ecec6_m.jpg" width="240" height="110" alt="harlaw_12" /> </a> </p> <p>A view of Harlaw Reservoir.</p>' (length=338)What I actually want is the photo (linked back) without the "Alf Thomas posted a photo" bit, does anyone have any idea how I would go about cloning that bit out? Edited by foucquet, 31 May 2014 - 08:14 AM. Hi all, Ive latly coded a option for my website which allowes users to send money. Ive finished coding it but when I press the submit button the money dont get sent to the other user it just puts it in the url bar. Example: http://********.com/newbank.php?touser=Test&sendmoney=1000000000&sendmoney=Send+Money! <?php session_start(); include ("includes/db_connect.php"); include ("includes/functions.php"); logincheck(); $username = $_SESSION['username']; // Fetch users stuff.. $fetch_u = mysql_query("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); $fetch_users = mysql_fetch_object($fetch_u); // Fetch bank stuff.. $fetch_b = mysql_query("SELECT * FROM bank") or die (mysql_error()); $fetch_bank = mysql_fetch_object($fetch_b); // User sending money.. if ($_POST['sendmoney']){ $send_money = strip_tags($_POST['ammount']); $to_user = strip_tags($_POST['touser']); if (!$to_user){ echo ("You must enter a username."); }elseif ($to_user){ $user_real = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username = '$to_user'")) or die (mysql_error()); if ($user_real == 0){ echo ("No such user!"); }elseif ($user_real != 0){ if ($send_money > "0"){ if ($send_money == 0 || !$send_money || ereg('[^0-9]',$send_money)){ echo ("You carnt send that type of money"); }elseif ($send_amount != 0 || $send_amount || !ereg('[^0-9]',$send_amount)){ if ($send_money > $fetch->money){ echo ("You havent got that much money"); }elseif ($send_money <= $fetch->money){ // Try sending money to yourself if (strtolower($to_user) == strtolower($username)){ echo ("You cannot send money to yourself"); }elseif (strtolower($to_user) != strtolower($username)){ $to_person = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$to_user'")); $otherusercash = $send_money; $otheruser = $to_user->money + $otherusercash; mysql_query("UPDATE users SET money = money-$send_money WHERE username='$username'"); mysql_query("UPDATE users SET money = '$otheruser' WHERE username='$to_person'"); $time = gmdate('Y-m-d h:i:s'); mysql_query("INSERT INTO `transfers` ( `id` , `to` , `from` , `amount` , `date` ) VALUES ('', '$to_person', '$username', '$send_amount', '$time')") or die (mysql_error()); echo "Money Sent!"; echo "<meta http-equiv=\"refresh\" content=\"0;URL=newbank.php\">"; } } } } } } } ?> <html> <head> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> .infobg { font-family: Arial; font-weight:normal; font-size:12px; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; background: URL(textbg1.png); font-weight:300; } .button { font-size: 12px; background:url(button.png); vertical-align: middle; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; color: #FFFFCC; height:23px; font-weight:300; border-radius: 10px; padding-bottom:2px; } </style> <title>Running-Mafia || Send Money</title> </head> <body> <form action='' name='form1'> <table width='50%' border='1' bordercolor='#000000' align='center' bgcolor='#808080' cellpadding='0' cellspacing='0' style='border-collapse: collapse'> <tr> <td colspan='2' background='header.jpg' align='center'>Send Money</td> </tr> <tr> <td> Username: </td> <td> <input type='text' name='touser' class='infobg' id='touser'> </td> </tr> <tr> <td> Ammout: </td> <td> <input name="sendmoney" class='infobg' type="text" id="send_money"> </td> </tr> <tr> <td> </td> <td> <input class="button" name="sendmoney" type="submit" id="sendmoney" value="Send Money!"> </td> </tr> </table> </form> </body> </html> Anyone see why its not sending the money? Thanks. let's say I have 100,000 users on my forum i want to cache there PROFILE INFO (About me) in .php files which is easy/etc but would that be more space than 100k rows in a db table, or 100k .php files? just wondering, prob a stupid question but atm I cache some lottery info and some other stuff, but that's only 1 .php it would be dumb to cache info and have 100k .php's for each user ID right? or maybe story it all in 1 .php? would be a HUGE Filesize? rather just keep the data in MYSQL right? Hello Guys... I'm new to php & mySQL... I need help... Need something to know... please help me... I'm using ubuntu 11.10, Aptana Studio 3, xampp 1.7.7. Also i'm using windows 7, notepad++ & wamp. When I visit "localhost" on my firefox. I saw a xampp or wamp welcome page. The name of the file is "index.php". 1. I need to know can I delete this file ? Bcoz i'm working on another file but it's the same file name. 2. When I upload my site on host like hostgator. How do i edit my live site? And preview it. 3. How do i store my post on database ? Like fb status update, blogger post or forum post I wanna write a site that i can post something without using html <p></p>. The main problem when i need to post something then everytime I need to edit the source code. Example:<p>some text here</p>. I don't wanna edit source everytime. Another Ques: Is Aptana Studio and notepad++ enough to write a site or I need another tool ? Any book suggestion ? please guys help me i'm new to php & mySQL.. Hi. I have built a form on a page call join.php On this form I pass a variable in this manner; $url = "thankyou.php?val_id=".$validation.""; header("Location: {$url}"); So on the next page (which is the thankyou for registering page I want this page on load to find the user from the $validation and then email the user. I have done this many times but for some reason this time the output is "No database selected!" There really is though. Also I can see in the browser window the code I have passed so its not like that is not working! Here is the code, can anyone see my error because I just have no idea whats up! <?php include(thedatabase.php'); session_start(); $val_id = $_GET['val_id']; $FullRec__query=sprintf("SELECT * FROM users WHERE val_id= %s", $val_id); $FullRec = mysql_query($FullRec__query) or die(mysql_error()); $userInfo = mysql_fetch_array($FullRec); $user = $userInfo['username']; mail($userInfo['email'],"Validation Link From Us","Dear ".$userInfo['username'].",\n\nThank you for signing up to www.thesite.co.uk. Please find below you validation link to gain access to the site.\n\n link:\nhttp://www.thesite.co.uk/val_entrance.php?validation_id=" . $_GET['val_id'] . "\n\nTeam site\n\n\n\nFor a full list of terms and conditions please go to the main area on your page and click the terms at the bottom of the page!"); ?> |