PHP - Reading/processing Variables Imported From Mysql
I have news articles which I distribute to various sites.
Each article contains various hyperlinks, which must resolve to a location on the site which pulled the article, i.e. Article: (hyperlink) Widgets are wonderful. Don Doe, president of (Widgets Incorporated) say they are cool. ------ Site A: To resolve to example.com/widget-companies/Widget-news/Widgets-Incorporated. Site B: To resolve to otherexample.com/Widgets-Incorporates/widget-news I'm paralyzed. The only thing I can think of is to bring the whole article in, and do a string replace. Some of the articles are 2k+ words. Even then, I have to come up with a way of pointing out the link text. I came up with $COMPANY:WIDGETS-INCORPORATED:Widget-Incorporated (UC WIDGETS to associate it with that company, and the mixed case Widget-Incorporated would be the hyperlink text. Explode it and use it. I am not even sure it will work, or if it works whether it is too inefficient. Should I try that, or something else? Similar Tutorialsdoes anyone know how to decode this XML variable value into string values? I also need to know the oposite way: creating variable values into xml. I've tried several code examples but they did filter the requested data. Code: [Select] $xml='<?xml version="1.0" encoding="utf-8"?> <elements> <text identifier="ed9cdd4c-ae8b-4ecb-bca7-e12a5153bc02"> <value/> </text> <textarea identifier="a77f06fc-1561-453c-a429-8dd05cdc29f5"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <textarea identifier="1a85a7a6-2aba-4480-925b-6b97d311ee6c"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <image identifier="ffcc1c50-8dbd-4115-b463-b43bdcd44a57"> <file><![CDATA[images/stories/red/cars/autobedrijf.png]]></file> <title/> <link/> <target/> <rel/> <lightbox_image/> <width><![CDATA[250]]></width> <height><![CDATA[187]]></height> </image> <text identifier="4339a108-f907-4661-9aab-d6f3f00e736e"> <value><![CDATA[Kramer 5]]></value> </text> <text identifier="ea0666d7-51e3-4e52-8617-25e3ad61f8b8"> <value><![CDATA[6000 RS]]></value> </text> <text identifier="90a18889-884b-4d53-a302-4e6e4595efa0"> <value><![CDATA[Eindhoven]]></value> </text> <text identifier="410d72e0-29b3-4a92-b7d7-f01e828b1586"> <value><![CDATA[APK Pick up and return]]></value> </text> <text identifier="45b86f23-e656-4a81-bb8f-84e5ea76f71f"> <value><![CDATA[15% korting op grote beurt]]></value> </text> <text identifier="3dbbe1c6-15d6-4375-9f2f-f0e7287e29f3"> <value><![CDATA[Gratis opslag zomerbanden]]></value> </text> <text identifier="2e878db0-605d-4d58-9806-8e75bced67a4"> <value><![CDATA[Gratis abonnement of grote beurt]]></value> </text> <text identifier="94e3e08f-e008-487b-9cbd-25d108a9705e"> <value/> </text> <text identifier="73e74b73-f509-4de7-91cf-e919d14bdb0b"> <value/> </text> <text identifier="b870164b-fe78-45b0-b840-8ebceb9b9cb6"> <value><![CDATA[040 123 45 67]]></value> </text> <text identifier="8a91aab2-7862-4a04-bd28-07f1ff4acce5"> <value/> </text> <email identifier="3f15b5e4-0dea-4114-a870-1106b85248de"> <value/> <text/> <subject/> <body/> </email> <link identifier="0b3d983e-b2fa-4728-afa0-a0b640fa34dc"> <value/> <text/> <target/> <custom_title/> <rel/> </link> <relateditems identifier="7056f1d2-5253-40b6-8efd-d289b10a8c69"/> <rating identifier="cf6dd846-5774-47aa-8ca7-c1623c06e130"> <votes><![CDATA[1]]></votes> <value><![CDATA[1.0000]]></value> </rating> <googlemaps identifier="160bd40a-3e0e-48de-b6cd-56cdcc9db892"> <location><![CDATA[50.895711,5.955427]]></location> </googlemaps> </elements>'; So here is what I have going. #1 - My weather station software processes a file and enters variables and then uploads it as a php file. #2 - Currently the station also just uploads every file to the site and enters the data in the html, but I would rather have it only upload this one file and the other pages grab data from it and print it out. I have a few php scrips in there to preform certain functions (if temp <= 32 it echos that data in blue and so on) but would rather make most of it php so I have less files being uploaded every 5 minutes. This is what the station sends to the web, but I have no idea how to get the other pages to read it and input the variables from it. So I have a text file "name.txt" in the text file I have ids and auth keys set up like this 1234564 abcdfhu 3123900 sdkoao etc How could I make it to where the ids are $ids and the auth keys are $auth_keys? I've tried using foreach() but I cant get it Hi everyone. I am David and I am new to web design and php. I am following a Lynda.com tutorial on php and sql. I have reached a certain point in the tutorial where I am reading values back from my database in to a php variable. The variable is holding an array data type and I am accessing the element within the array. I want a HTML select control and 2 radios buttons to reflect the values in the database. Therefore the Select control should read a numeric value of type int and the radio buttons are reflecting either a 1 or a 0. Firstly the code for the Select control uses a for loop to count the array elements and load the count into the Select control. The example uses php mixed with html. The for loop will count the number of element and add a number to the select control. The an If statment is used to make a decision if the count variable equals the value in the array element $sel_subject['position'] then select that value. This does not happen, and I can not seem to get it to work. <p>Position: <select name="position"> <!--use a php block so as to use some php variables --> <!--Use these variables with the get_all_sublects function. --> <!-- This function will return all the dataset --> <?php $sel_subject = get_all_subjects(); //Then use the mysql fuction to retuen the numberic value of all the rows. $subject_count = mysql_num_rows($sel_subject); //$subject_count + 1 becauce we are adding a subject for($count=1; $count <= $subject_count+1; $count++) { echo "<option value=\"{$count}\""; if ($sel_subject['position'] == $count) { echo " selected"; } echo ">{$count}</option>"; } ?> </select> </p> Secondly the radio buttons do something similar in that i want them to reflect the value in the array element. If a 1 then True and so be checked or 0 and so false and so be unchecked. <p>Visible: <input type= "radio" name= "visible" value= "0" <?php if ($sel_subject['visible'] == 0) { echo 'checked=" checked"'; } ?> >No</input> <input type= "radio" name= "visible" value= "1" <?php if ($sel_subject['visible'] == 1) { echo 'checked=" checked"'; } ?> >Yes</input> </p> Again this doesn't work either. So in summary, I cant get the php code to affect the html form controls and relay the stored data to the user. I have been racking my brain for days and getting no where. Please can anyone help me with this. I would be very grateful. All the best Irish_Dave I am pretty new to using php and mysql and am struggling to understand how to go about processing a multiple choice quiz script to check if the answer given by the user is right or wrong and give the user the final result . I understand how to write and process register pages and login scripts and the like but for some reason I just can't understand what i need to do for this type of script So far my thinking has been 1) When the page is submitted have a query that compares the answer selected to the answer in the database. 2) Have php variables for correct and and incorrect both initialised to 0 and which will change depending on the answers given. 3) Use an if else statement similar to the code below to add up the score : - if($result['answer']==$_POST[$result['id']]){ $correct_answer++; }else{ $incorrect_answer++; } 4) Have a query that enters the person taking the quiz's grade in to the database. I would really appreciate it someone could give me some guidance for the best way to do this. I have included below my code for selecting the questions form the database. <?php // Starts the session session_start(); /* */ if (!isset($_SESSION['user_level']) or ($_SESSION['user_level'] != 0)) { header("Location: error_page.php"); exit(); } ?> <?php require_once ('mysqli_connect.php'); $email_address = ['email_address']; $quizGradeBegan=("INSERT INTO learner_grade_db( email_address, score, )VALUES ('$email_address',0) "); $result=@mysqli_query($dbcon, $submittedAnswerQuery); if(isset($_SESSION['email_address'])){ ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Q-Quiz: Learner Homepage</title> <link rel="stylesheet" href="sdnt.css" /> </head> <body> <div class="wrapper"> <!-- Start of wrapper div --> <div class="header"> <!-- Start of header div --> <h1>e-Quiz: <br> Learner Homepage</h1> <?php //Makes a call to includes/leaner_nav.php in order to show The Learner Navigation Bar require_once("includes/learner_nav.php"); //Makes a call to includes/welcome_name.php in order to show the Learners name. require_once("includes/welcome_name.php"); /*Makes a call to includes/current_date in order to shows the current date. Will appear in the Day Month Year Format.*/ require_once("includes/current_date.php"); ?> <!-- Shows the Change text size images --> <div id="textSizer"><!-- Start of the textSizer div --> <img id="smallStyler" class="textSize" src="imgs/fontSmall.jpg" height="18" width="18" alt="Smallest" /> <img id="mediumStyler" class="textSize" src="imgs/fontMedium.jpg" height="18" width="18" alt="Default" /> <img id="largeStyler" class="textSize" src="imgs/fontLarge.jpg" height="18" width="18" alt="Biggest" /> </div> <!-- End of textsizer div --> </div><!-- End of Header div --> <div class="article"> <!-- Start of the article div --> <?php $query=("SELECT question_id, question, distractor_1, distractor_2, distractor_3, distractor_4 FROM multiplechoice_db ORDER BY RAND() LIMIT 3 " ); $result = @mysqli_query ($dbcon, $query); // Run the query. while($row = mysqli_fetch_array($result, MYSQL_BOTH)):?> <br> <form action="gradepage.php" method="post"> <?php echo $row['question_id'];?> <br> <?php echo $row['question'];?> <br> <input type="radio" value="1" id=' distractor <?php echo $row['question_id'];?>' name ='<?php echo $row['question_id'];?>'/><?php echo $row['distractor_1'];?> <br> <input type="radio" value="2" id=' distractor <?php echo $row['question_id'];?>' name ='<?php echo $row['question_id'];?>'/><?php echo $row['distractor_2'];?> <br> <input type="radio" value="3" id=' distractor <?php echo $row['question_id'];?>' name ='<?php echo $row['question_id'];?>'/><?php echo $row['distractor_3'];?> <br> <input type="radio" value="4" id=' distractor <?php echo $row['question_id'];?>' name ='<?php echo $row['question_id'];?>'/><?php echo $row['distractor_4'];?> <br> <?php endwhile;?> <p> <input id="submit" type="submit" name="submit" value="Click To Submit Completed Quiz "></> </div> <!-- End of the article div --> <div class="aside"> <!-- Start of the aside div --> <ul class="nav2"> <?php //Makes a call to includes/leanersidebar1.php in order to show The Learner Sidebar require_once("includes/learnersidebar1.php"); ?> </ul> <br><br><br><br><br> </div> <!-- End of the aside div --> <div class="footer "><!-- Start of the footer div --> <?php //Makes a call to includes/footer.php in order to show the Footer require_once("includes/footer.php"); ?> </div><!-- End of the footer div --> </div><!-- End of the wrapper div --> </body> <html> I have a normalized database in the form of Code: [Select] ID user_id key value 1 3 first_name Brian 2 3 last_name Tardy 3 4 first_name John 4 4 last_name Wilson What is the fastest way to capture these values within php? I want to perform a SELECT to catch the values for every user as Code: [Select] $result=mysql_query("SELECT * FROM users_data WHERE user_id = '$id'"); while($row=mysql_fetch_array($result)) { here we process all data for a given user and write it to text file as a single line } Since it is a long list (100K users with about 10M of rows in user_data), I am looking for the fastest and most reliable way to scan all the database. ?> I am reading in a table and ordering it by a column labeled "sub" and generating an HTML table. The "sub" column entries are in numerical order (i.e. 1 2 3 4 5 6 7 8 10 11 12 etc. etc.). There are over 100 entries in this table as well. The problem I'm facing is probably obvious to some of you as the display is
1 Obviously I'd like the display to be in numerical order.
What can I do?
Hello
Is it possible to save data from saved htm table from other website in our mysql database system
as I have problem that there is one htm page where i can get data but i want to save it in mysql table. as data is large on htm page
it was hard to copy so i want access it direct from php and save it in mysql table
please guide
awaiting your valuable reply.
Thank in advance
Hi All, Is there a way we can write a PHP script to automatically read receive emails, extract csv file attachment from there and insert into MySQL database then run this in Cron Jobs to automate the process? Hi All, Is there a way we can write a PHP script to automatically read receive emails, extract csv file attachment from there and insert into MySQL database then run this in Cron Jobs to automate the process? I have a list of names in a table and I am trying to search a website with each of these names. Can someone point me in the right direction if I want to POST each name to the site and use cURL to get the information(did this part already). Will a simple Loop or While command do the job? I'm getting data from a remote XML file using the following as a result of a form: Code: [Select] <?php header('Content-type: text/xml'); //extract data from the post extract($_POST); //set POST variables $url = 'https://www.*******'; $fields = array( 'ESERIES_FORM_ID'=>urlencode($ESERIES_FORM_ID), 'MXIN_USERNAME'=>urlencode($MXIN_USERNAME), 'MXIN_PASSWORD'=>urlencode($MXIN_PASSWORD), 'MXIN_VRM'=>urlencode($MXIN_VRM), 'MXIN_TRANSACTIONTYPE'=>urlencode($MXIN_TRANSACTIONTYPE), 'MXIN_PAYMENTCOLLECTIONTYPE'=>urlencode($MXIN_PAYMENTCOLLECTIONTYPE), 'MXIN_CAPCODE'=>urlencode($MXIN_CAPCODE) ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); ?> Which is displaying what was the remote XML page, but has brought it to my domain. How would I go about taking the results of the displaying XML page and displaying them on the next page rather than just displaying the XML data? Many thanks in advanced! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=353212.0 Hi my website has been working all day now everypage is getting this error also get the same error when i try to login into phpmyadmin Lost connection to MySQL server at 'reading initial communication packet', system error: 111 is this most likely a problem with the server? Just a quick one for anyone here that knows. I am setting up a small catalog site that runs off a MySQL database. On each product page there is a main image and six supporting thumbnails of different views of said product. I have six thumbnails (front, back, left, right, modelimage1, modelimage2) with then six main images to match. I want to be able to click on each of the thumbnails and have it swap the main image to match. I have given the main image an ID so maybe I could use a bit of javascript to swap the mainimage1 (<? echo "$mainimage1"; ?>) ....... to........ mainimage2 (<? echo "$mainimage2"; ?>) when i click on Any ideas of where to start? Its really just a simple thumbnail gallery i guess! I'm a newbie so as simple as possible would be great! Code: [Select] $id = $_GET['id']; // will be equal to '1' if the url ends in ?id=1 it would be '2' if it ended in ?id=2 etc. $query="SELECT * FROM ruxxshop WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $name=mysql_result($result,$i,"name"); $subtitle=mysql_result($result,$i,"subtitle"); $description=mysql_result($result,$i,"description"); $colour=mysql_result($result,$i,"colour"); $standardprice=mysql_result($result,$i,"standardprice"); $standardshoplink=mysql_result($result,$i,"standardshoplink"); $largeprice=mysql_result($result,$i,"largeprice"); $largeshoplink=mysql_result($result,$i,"largeshoplink"); //main images $mainimage1=mysql_result($result,$i,"mainimage1"); //front image $mainimage2=mysql_result($result,$i,"mainimage2"); //back image $mainimage3=mysql_result($result,$i,"mainimage3"); //left image $mainimage4=mysql_result($result,$i,"mainimage4"); //right image $mainimage5=mysql_result($result,$i,"mainimage5"); //model image 1 $mainimage6=mysql_result($result,$i,"mainimage6"); //model image 2 //thumbnail images $leftimage=mysql_result($result,$i,"leftimage"); $rightimage=mysql_result($result,$i,"rightimage"); $backimage=mysql_result($result,$i,"backimage"); $frontimage=mysql_result($result,$i,"frontimage"); $modelimage1=mysql_result($result,$i,"modelimage1"); $modelimage2=mysql_result($result,$i,"modelimage2"); ?> <style type="text/css"> <!-- .areasmenu { font-size: 13px; color: #CCC; } .basemenu { text-align: left; font-size: 9px; font-family: Verdana, Geneva, sans-serif; } .rightalignmenu { font-family: Verdana, Geneva, sans-serif; font-size: 10px; font-style: normal; color: #999; text-align: right; vertical-align: top; } .thumbtable { background-color: #E2E2E2; } .maintable { background-image: url(Images/Main%20Content/background.jpg); } .BagTitle { color: #666; font-size: 14px; font-family: Verdana, Geneva, sans-serif; font-weight: bold; vertical-align: top; } .leftaligntext { font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #666; vertical-align: top; } .rightaligntext { font-family: Verdana, Geneva, sans-serif; font-size: 11px; color: #666; text-align: right; vertical-align: top; } .thumbpics { font-size: 7px; } a:link { color: #999; text-decoration: none; } a:visited { text-decoration: none; color: #999; } a:hover { text-decoration: none; color: #999; } a:active { text-decoration: none; color: #999; } --> </style> <p> <? ++$i; }; ?> </p> <p> </p> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th rowspan="2" align="left" valign="top" scope="col"><a href="grid.html"><img src="Images/Main Content/Ruxx Logo Black.jpg" alt="Home Page" width="100" height="28" border="0" /></a> </th> <th width="316" height="20" valign="top" class="rightalignmenu" scope="col"><span class="areasmenu"><a href="/grid1.html">WOMENS</a></span></th> <th width="74" height="20" valign="top" class="rightalignmenu" scope="col"><span class="areasmenu">MENS</span></th> <th width="131" height="20" valign="top" class="rightalignmenu" scope="col"><span class="areasmenu">ACCESSORIES</span></th> </tr> <tr> <td height="20" colspan="3" class="rightalignmenu"><a href="index.html">Home</a> - <a href="/about.html">About Ruxx</a>- The Ruxx Store - Bag Sizing & Details - <a href="/contact.html">Contact</a> - Register For Info</td> </tr> </table> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="maintable" valign="middle" > <tr class="greybackground"> <td width="230" height="440" valign="top"><table width="230" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="30" height="60" nowrap="nowrap"> </td> <td height="60"> </td> <td width="20" height="60" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="15" nowrap="nowrap"> </td> <td height="15" class="BagTitle"><font face="Arial, Helvetica, sans-serif"><? echo "$name"; ?></font></td> <td width="20" height="15" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="15" nowrap="nowrap"> </td> <td height="15" class="leftaligntext"><font face="Arial, Helvetica, sans-serif"><? echo "$subtitle"; ?></font></td> <td width="20" height="15" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="50" nowrap="nowrap"> </td> <td height="50"> </td> <td width="20" height="50" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="100" nowrap="nowrap"> </td> <td height="100" class="leftaligntext"><font face="Arial, Helvetica, sans-serif"><? echo "$description"; ?></font></td> <td width="20" height="100" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="55" nowrap="nowrap"> </td> <td height="55"> </td> <td width="20" height="55" nowrap="nowrap"> </td> </tr> <tr> <td width="30" height="100" nowrap="nowrap"> </td> <td height="100" class="leftaligntext"><font face="Arial, Helvetica, sans-serif"><? echo "$colour"; ?></font></td> <td width="20" height="100" nowrap="nowrap"> </td> </tr> </table></td> <td valign="top"><img src="<? echo "$mainimage1"; ?>" width="340" height="440" name="MainImage" /></td> <td width="230" valign="top"><table width="230" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" height="60"> </td> <td height="60"> </td> <td width="30" height="60"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif">STANDARD SIZE</font><font face="Arial, Helvetica, sans-serif">: <? echo "$standardprice"; ?></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$standardshoplink"; ?>">Buy This Bag</a></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="40"> </td> <td height="40"> </td> <td width="30" height="40"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif">LARGE SIZE</font><font face="Arial, Helvetica, sans-serif">: <? echo "$largeprice"; ?></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="15"> </td> <td height="15" class="rightaligntext"><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$largeshoplink"; ?>">Order This Bag</a></font></td> <td width="30" height="15"> </td> </tr> <tr> <td width="20" height="20"> </td> <td height="20"> </td> <td width="30" height="20"> </td> </tr> <tr> <td width="20" height="200"> </td> <td height="200"><table width="150" border="0" align="right" cellpadding="0" cellspacing="5" class="thumbtable"> <tr> <td height="60"><img src="<? echo "$frontimage"; ?>" width="65" height="65" /></td> <td height="60"><img src="<? echo "$backimage"; ?>" width="65" height="65" /></td> </tr> <tr> <td height="60"><img src="<? echo "$leftimage"; ?>" width="65" height="65" /></td> <td height="60"><img src="<? echo "$rightimage"; ?>" width="65" height="65" /></td> </tr> <tr> <td height="60"><img src="<? echo "$modelimage1"; ?>" width="65" height="65" /></td> <td height="60"><img src="<? echo "$modelimage2"; ?>" width="65" height="65" /></td> </tr> </table></td> <td width="30" height="0"> </td> </tr> </table></td> </tr> </table> <table width="800" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="15" valign="bottom" class="areasmenu"><span class="basemenu">Terms & Conditions - Refund Policy - Privacy Policy - Delivery Info - Copyright Ruxx 2010 ©</span></td> </tr> </table> Thanks Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. Hey Guys, I have to insert some data in MySQL but it wont work . Please have a look. <?php // to values are set to empty $vatsim=""; $ivao=""; // values from form in other page are set if(isset($_POST["pilotid"])) $pilotid=$_POST["pilotid"]; if(isset($_POST["network"])) $network=$_POST["network"]; if(isset($_POST["vid"])) $vid=$_POST["vid"]; if(isset($_POST["pilot"])) $pilot=$_POST["pilot"]; // if value is that copy data in this value, otherways in that value if ($network == "IVAO") { $ivao="$vid";} if ($network == "VATSIM") { $vatsim="$ivao";} // connect db include(dbconnect.inc.php); // first sql to update some data in one table $sql = "UPDATE `360283`.`jos_users` SET `IPS` = \'1\' WHERE `jos_users`.`id` = \'$pilotid\'"; $result1 = mysql_query($sql); // 2nd sql to insert some data in other table $sql2 = "INSERT INTO `360283`.`IPS_Pilots` (`ID`, `Name`, `Hours`, `Flights`, `LastFlight`, `IVAO`, `VATSIM`, `Enabled`, `Rating`) VALUES ('$pilotid', '$pilot', NULL, NULL, NULL, '$ivao', '$vatsim', '1', '0');"; $result2 = mysql_query($sql2); // sql to check if it was succesful $sql3 = "SELECT * FROM `IPS_Pilots` WHERE `ID` = '$pilotid' LIMIT 0, 30 "; $result3 = mysql_query($sql3); $num3 = mysql_numrows($result3); // echo succesfull or not if (!$num3) { echo "Sorry, but I failed to apply this pilot."; } else { echo "Pilot succesfully applied."; } ?> Thanks Hi All! I've written up a script for my website. It\ is basically a virtual job quest. My queries are all correct it just isn't registering the variable for the session. It is $-SESSION[theid']. I want to be bale to use it in my table but I get an error. How do I write this in my SQL query for it to work. The page (when no errors), doesn't show my data. Here is my ocde: Code: [Select] <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content><content><center><font size=6>Messages</font><br><br></center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar><img src=/images/layout/player.gif><a href=status.php>$showusername</a>.......................<img src=/images/layout/coin.gif> $scredits</ubar><content><center><font size=6>Basic Quests</font><br><br>"; $startjob = $_POST['submit']; $jobq = "SELECT * FROM jobs WHERE username='$showusername'"; $job = mysql_query($jobq); $jobnr = mysql_num_rows($job); if($jobnr == "0") { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="submit" value="Start Job"></form> <?php } if(isset($startjob)) { $initemidq = "SELECT * FROM items ORDER BY RAND() LIMIT 1"; $initemid = mysql_query($initemidq); while($ir = mysql_fetch_array($initemid)) { $ids = $ir['itemid']; } mysql_query("INSERT INTO jobs (username, item, time, completed) VALUES ('$showusername', '$ids', 'None', 'No')"); $wegq = "SELECT * FROM items WHERE itemid='$ids'"; $weg = mysql_query($wegq); while($wg = mysql_fetch_array($weg)) { $im = $wg['image']; $nm = $wg['name']; $id = $wg['itemid']; } $_SESSION['theid'] = $id; echo "<font color=green>Success! You have started this Job!</font><br><br>Please bring me this item: <b>$nm</b><br><br><img src=/images/items/$im><br><br><br>"; echo $_SESSION['theid']; } if($jobnr == "1") { $finish = $_POST['finish']; $okgq = "SELECT * FROM items WHERE itemid='$yes'"; $ok = mysql_query($okgq); while($ya = mysql_fetch_array($ok)) { $okname = $ya['name']; $okid = $ya['itemid']; $okimage = $ya['image']; } echo "Where is my <b>$okname</b>?<br><br><img src=/images/items/$okimage><br><br><br>"; echo $_SESSION['theid']; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="finish" value="I have the Item"></form> <?php } } if(isset($finish)) { $cinq = "SELECT * FROM uitems WHERE theitemid='$_SESSION[theid]'"; $cin = mysql_query($cinq); $connr = mysql_num_rows($cin); if($connr != "0") { echo "<font color=green>Success! You have the item.</font>"; } else { echo "<font color=red>Error! You do not have my item!</font>"; } } ?> . I basically just want to know how I can set this session as a variable. Also..I have a user login on every page and I want to be able to destroy JUST THE "theid" session and NOT the username session. How would I do that too? thanks for the help in advance! Ok so I have this script which will take a propery formated .csv file and upload to my database. here's the part i need to know if it's possible. basically it puts a group of codes into the database but i need a field that will specify which user the code pertains to from another table. The most logical way to reference the user is with an id code; but short of having the user reference an id code to put in the csv file, is there anyway I can make a query that will INSERT INTO and upload the csv? here's my current code... <?php $tmpName = $_FILES['song_codes']['tmp_name']; include('database.php'); if($sc != ""){ mysql_query('LOAD DATA LOCAL INFILE \''.$tmpName.'\' INTO TABLE music_codes FIELDS ENCLOSED BY "\"" TERMINATED BY "," LINES TERMINATED BY "\n" ;') or die('Error loading data file.<br>' . mysql_error()); |