PHP - Inserting Info From Text File Into Database....not Working...
I've created a function to update the database with the information from the text file...I've already got additional code (not posted here) that displays the orders that have NOT been shipped (and works beautifully). Then when they click the button it should process the text file and update the database (input the tracking number into the database) and change the order status and send an email to the customer, I know I've got something mixed up because it's not working...
function process_shipping($ordernumber, $status=''){ $order_updated = false; $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . $ordernumber . "'"); $check_status = tep_db_fetch_array($check_status_query); $orders_statuses = array(); $orders_status_array = array(); $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = 1"); while ($orders_status = tep_db_fetch_array($orders_status_query)) { $orders_statuses[] = array('id' => $orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } if ($status!==''){ if ($check_status['orders_status'] !== $status) { tep_db_query("update " . TABLE_ORDERS . " set fedex_track_num = '" . $tracking . "'orders_status = '". $status . "', last_modified = now() where orders_id = '" . $oID . "'"); $customer_notified = '0'; $notify_comments = ''; $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]); tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $customer_notified = '1'; tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments) . "')"); $order_updated = true; } } } if ($_POST['update']=='1') { echo '<div class="dataTableContent" align="left">'; $arr=file("/home/onest4/public_html/beta/fedex.txt"); $x=1; foreach($arr as $str){ if (trim($str) != ''){ if ($x > 3){ list($tracking,$oID)=explode(" ",$str); if(ctype_digit($tracking)){ echo "Order# $oID, <b>$tracking</b> (DATABASE UPDATED)<br>"; } }else{ $x++; continue; } } } } Similar TutorialsHi, first time poster here. Pretty new to PHP. Yesterday my PHP code was inserting into my MySQL database fine and as of today it isn't inserting anything into the database. Is there any common error in my PHP code that i'm forgetting? I'm using XAMPP. I think I may be posting in the wrong area. Also any pointers on my code would be appreciated. Below is my code: <html> <head> <title> Sign up! </title> </head> <body> <form id = "signup" method = "post" action = "<?php echo $_SERVER['PHP_SELF'];?>" onsubmit= "return formValidator()"> Please enter your name: <input type = "text" id = "name"> <br /> Please enter the password you would like: <input type ="password" id = "password"/> <br /> Please enter your Date Of Birth : <select type ="text" size = "1" id = "dayofbirth"/> <option value = "1"> 01 </option> <option value = "2"> 02 </option> <option value = "3"> 03 </option> <option value = "4"> 04 </option> <option value = "5"> 05 </option> <option value = "6"> 06 </option> <option value = "7"> 07 </option> <option value = "8"> 08 </option> <option value = "9"> 09 </option> <option value = "10"> 10 </option> <option value = "11"> 11 </option> <option value = "12"> 12 </option> <option value = "13"> 13 </option> <option value = "14"> 14 </option> <option value = "15"> 15 </option> <option value = "16"> 16 </option> <option value = "17"> 17 </option> <option value = "18"> 18 </option> <option value = "19"> 19 </option> <option value = "20"> 20 </option> <option value = "21"> 21 </option> <option value = "22"> 22 </option> <option value = "23"> 23 </option> <option value = "24"> 24 </option> <option value = "25"> 25 </option> <option value = "26"> 26 </option> <option value = "27"> 27 </option> <option value = "28"> 28 </option> <option value = "29"> 29 </option> <option value = "30"> 30 </option> <option value = "31"> 31 </option> </select> <select type ="text" size = "1" id = "monthofbirth"/> <option value = "1">January</option> <option value = "2">February</option> <option value = "3">March</option> <option value = "4">April</option> <option value = "5">May</option> <option value = "6">June</option> <option value = "7">July</option> <option value = "8">August</option> <option value = "9">September</option> <option value = "10">October</option> <option value = "11">November</option> <option value = "12">December</option> </select> <select type ="text" size = "1" id = "yearofbirth"/> <option value = "1994">1994</option> <option value = "1993">1993</option> <option value = "1992">1992</option> <option value = "1991">1991</option> <option value = "1990">1990</option> <option value = "1989">1989</option> <option value = "1988">1988</option> <option value = "1987">1987</option> <option value = "1986">1986</option> <option value = "1985">1985</option> <option value = "1984">1984</option> <option value = "1983">1983</option> <option value = "1982">1982</option> <option value = "1981">1981</option> <option value = "1980">1980</option> <option value = "1979">1979</option> <option value = "1978">1978</option> <option value = "1977">1977</option> <option value = "1976">1976</option> <option value = "1975">1975</option> <option value = "1974">1974</option> <option value = "1973">1973</option> <option value = "1972">1972</option> <option value = "1971">1971</option> <option value = "1970">1970</option> <option value = "1969">1969</option> <option value = "1968">1968</option> <option value = "1967">1967</option> <option value = "1966">1966</option> <option value = "1965">1965</option> <option value = "1964">1964</option> <option value = "1963">1963</option> <option value = "1962">1962</option> <option value = "1961">1961</option> <option value = "1960">1960</option> <option value = "1959">1959</option> <option value = "1958">1958</option> <option value = "1957">1957</option> <option value = "1956">1956</option> <option value = "1955">1955</option> <option value = "1954">1954</option> <option value = "1953">1953</option> <option value = "1952">1952</option> <option value = "1951">1951</option> </select> <br /> Please enter your e-mail address: <input type ="text" id = "email"/> <br /> Please enter your address: <input type ="text" id = "address"/> <br /> Please enter your city: <input type ="text" id = "city"/> <br /> Please enter your postcode <input type ="text" id = "postcode"/> <br /> Please enter your telephone number: <input type ="text" id = "telephoneno"/> <br /> <input type= "submit" id = "submit" value ="Submit me!"/> </body> <?php $conn = mysql_connect("localhost", "root", "") or die("cannot connect server "); mysql_select_db("nightsout") or die ("cannot find database"); if(isset($_POST['submit'])) { $username = $_POST['name']; $password = $_POST['password']; $day = $_POST['dayofbirth']; $month = $_POST['monthofbirth']; $year = $_POST['yearofbirth']; $date = ($year.'-'.$month.'-'.$day); $email = $_POST['email']; $address = $_POST['address']; $city = $_POST['city']; $postcode = $_POST['postcode']; $telephoneno = $_POST['telephoneno']; $duplicate = mysql_query("SELECT * FROM users WHERE emailaddress = '$email'", $conn) or die('Cannot Execute:'. mysql_error()); if(mysql_num_rows($duplicate) == 0) { mysql_query("INSERT INTO users (username, password, DOB, emailaddress, address, city, postcode, telephonenumber) VALUES ('{$username}', '{$password}', '{$date}', '{$email}' ,'{$address}', '{$city}', '{$postcode}', '{$telephoneno}')"); }else if(mysql_num_rows($duplicate) > '1') { ?> <p>This E-mail address already exists please use another one or <a href="home.php">Login.</a> </p> <?php } } mysql_close($conn); ?> Many thanks. As per the client requirement he wants to read words from a file and want to insert them in database one by one . ie a confirmation is required whether he wants to insert is or not. I have developed the thing but the problem is when i am retrieving the words it asks for all the words. i will show u wat the problem is. My main query is i want to pause the exectution until user's input. Code: [Select] <script type="text/javascript" src="jquery.js"></script> <script type"text/javascript"> function show() { document.getElementById('form#submit').fadeIn(); alert("Abhinav"); } $(document).ready(function(){ $("form#submit").submit(function() { // we want to store the values from the form input box, then send via ajax below var word = $('#word').attr('value'); var synonym = $('#synonym').attr('value'); $.ajax({ type: "POST", url: "ajax.php", data: "word="+ word + "&synonym=" + synonym, success: function(){ $('form#submit').hide(); //$('form#submit :input').val(""); $('div.success').fadeIn(); } }); return false; }); }); </script> <?php $file=fopen("welcome.txt","r") or exit("Unable to open file!"); @$word=""; @$c=""; while (!feof($file)) { $c=fgetc($file); if(strcmp($c," ")==0) { echo "". "<form id='submit' method='post' name='submit' action='' >". "<fieldset> ". "<legend>Enter Information</legend> ". " <label for='word'>Word:</label> ". "<input id='word' class='text' name='word' size='20' type='text' value='$word' > ". " <label for='Synonym'>Synonym:</label> ". "<input id='synonym' class='text' name='synonym' size='20' type='text'> ". " <button class='button positive' type='submit'> Add Client </button> ". " </fieldset> ". " </form> ". "<div class='success' style='display:none;'>Client has been added.</div> ". "</div>"; $word=""; } else $word=$word.$c; } fclose($file); ?> Now what i want is after user clicks add client then only next insertion box must be shown. please check the attached image to see the output. Guys pls help me over this. Thnx in advance Okay, I'll make this short and sweet, and all side comments are irrelevant. I'm doing this for my own happies So using Facebook.com's API you can extract all of a specific user's friends in an array. Well I'm making a array check to see who on that users friend list was removed or deleted them that week using array_dif(); in this method: 1) User allows the application 2) Application catches the user's friends_id's in an array and stores them // this is where i'm having trouble, i'll come back to it 3) User then waits a few days and notices their friend count is no longer 400, it's now 399! 4) User logs into my application, and checks the previously uploaded array against their current array of friends. Okay now to the part i'm struggling with is, what would you do? Should i store them each uniquely in a database? Because some users have 4,000+ friends and that gets quite strenuous. OR! Should i save them into a txt file unique to that person's user_id. I kind of like the 2nd option, however it's less ( to my newbish mind ) customizable versus the sql_queries. Once again, i'd like to reiterate, i don't care that this is again Facebooks terms of service, it's for my own personal gain and just enjoy taking on projects in my spare time that force my brain to work hard. That's all, hope you excuse the typos and poor grammar. Typed this pretty quickly, any questions - feel free to ask! Hello,
Trying to rearrange a data on the website. Looks normal when looking through preview on IE and chrome. But once moved to live website, the whole alignment changes from left to center , including the text that needs to show up. I am a newbie to coding and dont have a clue. tried puttng something together based on what i foud on the web. attaching screenshot and the code that i did. any help is highly appreciated. also attached is a screenshot of what happens when the php file is uploaded. Prior to doing that, the menu on the left is aligned properly and the assets that we have show properly.
What we are trying to do is rearrage the whole assets into different categories.
many thanks
Attached Files
portfolio.php 3.27KB
2 downloads
noalignment.png 11KB
0 downloads Hello, me again. I have created a little forum - very very basic. main_forum.php : Code: [Select] <?php $host="localhost"; // Host name $username="yvonnedp"; // Mysql username $password="yvonne"; // Mysql password $db_name="forum"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select databse. mysql_connect('localhost', 'yvonnedp', 'yvonne')or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> create_topic.php : Code: [Select] <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="add_topic.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td> </tr> <tr> <td width="14%"><strong>Topic</strong></td> <td width="2%">:</td> <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td> </tr> <tr> <td valign="top"><strong>Detail</strong></td> <td valign="top">:</td> <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td> </tr> <tr> <td><strong>Name</strong></td> <td>:</td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table> add_topic.php : Code: [Select] <?php $host="localhost"; // Host name $username="yvonnedp"; // Mysql username $password="yvonne"; // Mysql password $db_name="forum"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select database. mysql_connect('localhost', 'yvonnedp', 'yvonne')or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $datetime=date("d/m/y h:i:s"); //create date time $sql="INSERT INTO $tbl_name(topic, detail, name, datetime)VALUES('$topic', '$detail', '$name', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; $email_from = "forums@thenewme.co.za"; $email_to = "info@thenewme.co.za"; $email_subject = "The New Me - New Forum Topic"; $email_message = "A new topic has been posted on the Forum!\n"; $email_message .= "Check it out : http://www.thenewme.co.za/forum/main_forum.php"; $headers = 'From: '.$email_from."\r\n"; 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); } else { echo "ERROR"; } mysql_close(); ?> add_answer.php : Code: [Select] <?php $host="localhost"; // Host name $username="yvonnedp"; // Mysql username $password="yvonne"; // Mysql password $db_name="forum"; // Database name $tbl_name="forum_answer"; // Table name // Connect to server and select databse. mysql_connect('localhost', 'yvonnedp', 'yvonne')or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get value of id that sent from hidden field $id=$_POST['id']; // Find highest answer number. $sql="SELECT MAX(a_id) AS Maxa_id FROM $tbl_name WHERE question_id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); // add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 if ($rows) { $Max_id = $rows['Maxa_id']+1; } else { $Max_id = 1; } // get values that sent from form $a_name=$_POST['a_name']; $a_answer=$_POST['a_answer']; $datetime=date("d/m/y H:i:s"); // create date and time // Insert answer $sql2="INSERT INTO $tbl_name(question_id, a_id, a_name, a_answer, a_datetime)VALUES('$id', '$Max_id', '$a_name', '$a_answer', '$datetime')"; $result2=mysql_query($sql2); if($result2){ echo "Successful<BR>"; echo "<a href='view_topic.php?id=".$id."'>View your answer</a>"; // If added new answer, add value +1 in reply column $tbl_name2="forum_question"; $sql3="UPDATE $tbl_name2 SET reply='$Max_id' WHERE id='$id'"; $result3=mysql_query($sql3); $email_from = "forums@thenewme.co.za"; $email_to = "info@thenewme.co.za"; $email_subject = "The New Me - New Forum Answer"; $email_message = "A new answer to a forum topic has been posted on the Forum!\n"; $email_message .= "Check it out : http://www.thenewme.co.za/forum/main_forum.php"; $headers = 'From: '.$email_from."\r\n"; 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); } else { echo "ERROR"; } mysql_close(); ?> view_topic : Code: [Select] <?php $tbl_name2="forum_answer"; // Switch to table "forum_answer" $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'"; $result2=mysql_query($sql2); while($rows=mysql_fetch_array($result2)){ ?> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#F8F7F1"><strong>ID</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_id']; ?></td> </tr> <tr> <td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td> <td width="5%" bgcolor="#F8F7F1">:</td> <td width="77%" bgcolor="#F8F7F1"><? echo $rows['a_name']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Answer</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_answer']; ?></td> </tr> <tr> <td bgcolor="#F8F7F1"><strong>Date/Time</strong></td> <td bgcolor="#F8F7F1">:</td> <td bgcolor="#F8F7F1"><? echo $rows['a_datetime']; ?></td> </tr> </table></td> </tr> </table><br> <? } $sql3="SELECT view FROM $tbl_name WHERE id='$id'"; $result3=mysql_query($sql3); $rows=mysql_fetch_array($result3); $view=$rows['view']; // if have no counter value set counter = 1 if(empty($view)){ $view=1; $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'"; $result4=mysql_query($sql4); } // count more value $addview=$view+1; $sql5="update $tbl_name set view='$addview' WHERE id='$id'"; $result5=mysql_query($sql5); mysql_close(); ?> the problem is. With add_answer, I am not able to insert an answer. This has worked for the very first question, but all subsequent questions, I am unable to add answers. It keeps telling me ERROR. This is where the live forum is : http://www.thenewme.co.za/forum/main_forum.php Can it be an issue with the field that gets autmatically incremented? i have echo'd the data which get entered in when someone types in an answer, and everything is perfect! Can anyone help me? I have a standard form that displays users current data from a mysql database once logged in(code obtained from the internet). Users can then edit their data then submit it to page called editform.php that does the update. All works well except that the page does not display the updated info. Users have to first logout and login again to see the updated info. even refreshing the page does not show the new info. Please tell me where the problem is as i am new to php.
my form page test.php
<?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } ?> <form action="editform.php?id_user=<?= $fgmembersite->UserId() ?>" method="POST"> <input type="hidden" name="id_user" value="<?= $fgmembersite->UserId() ?>"><br> Name:<br> <input type="text" name="name" size="40" value="<?= $fgmembersite->UserFullName() ?>"><br><br> Email:<br> <input type="text" name="email" size="40" value="<?= $fgmembersite->UserEmail() ?> "><br><br> Address:<br> <input type="text" name="address" size="40" value="<?= $fgmembersite->UserAddress() ?> "><br><br> <button>Submit</button>my editform.php <?php $con = mysqli_connect("localhost","root","user","pass"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_query($con,"UPDATE fgusers3 SET name = '".$_POST['name']."', email= '".$_POST['email']."', address= '".$_POST['address']."' WHERE id_user='".$_POST['id_user']."'"); header("Location: test.php"); ?> This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=315983.0 I'm testing out small bits of code for myself, and I'm trying to understand why this isn't coming out how I would imagine it to... I have my function which stores colors in an array from a text file, then I return back a random color from my array like so... function getColor() { $ball_color = explode("\n", file_get_contents('colors.txt')); // Takes file contents and stores them into an array. return $ball_color[array_rand($ball_color)]; } And now in the main program, I simply have this: $color = getColor(); switch($color) { Case "blue": // echo stuff break; Case "red": // echo stuff break; etc... } For some reason though, my switch statement always reads the default case, making me assume that the words "blue" "red" "green" etc... aren't matching up to what I have set the cases at. When I output what color is actually being read, it displays exactly as it should, so I don't understand why the case "red" isn't opening up when that color is chosen, or same with any of the other colors. Is there some small conflict I'm unaware of in this tiny practice code? Any help is appreciated, thanks. I have created a form that i can see the form input info in to the form boxes but once submitted it is not updating or adding new input to the database. I am trying to keep it as simple as possible. I am also new at PHP.
Here is my code:
<?php // define variables and set to empty values $amp_20_parts_idErr = $part_numberErr = $locationErr = $quantityErr = ""; $amp_20_parts_id = $part_number = $discription = $location = $quantity = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["amp_20_parts_id"])) { $amp_20_parts_idErr = "ID is required."; } else { $amp_20_parts_id= test_input($_POST["amp_20_parts_id"]); } if (empty($_POST["part_number"])) { $part_numberErr = "Part number is required."; } else { $email = test_input($_POST["part_number"]); } if (empty($_POST["description"])) { $descriptionErr = ""; } else { $description = test_input($_POST["description"]); } if (empty($_POST["location"])) { $locationErr = "A location is required."; } else { $location = test_input($_POST["location"]); } if (empty($_POST["quantity"])) { $quantityErr = "Quantity is required"; } else { $quantity = test_input($_POST["quantity"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <div id="update_form"> Please follow instructions for updating the data base.<br>instructional text goes here.<br/><br/> <table><tr><form method="POST" action="new path"> <td>ID: <input name="amp_20_parts_id" type="text"><span><?php echo $amp_20_parts_idErr; ?></span><br/><br/></td> <td>Part Number: <input name="part_number" type="text"><span><?php echo $part_numberErr; ?></span><br/><br/></td> <td><label>Discription: <textarea name="description" rows="3" col="20"></textarea> <br/><br/></td> <td>Location: <input name="location" type="text"><span><?php echo $locationErr;?> </span><br/><br/></td> <td>Quantity: <input name="quantity" type="text"><span><?php echo $quantityErr; ?> </span><br/><br/></td><br/> <td><input type="submit"></td> </form></tr></table> <?php $con=mysqli_connect("server","user","password","db"); // Check connection if (mysqli_connect_errno()) { echo("Connect failed: %s\n", mysqli_connect_error()); // escape variables for security $amp_20_parts_id = mysqli_real_escape_string($con, $_POST['amp_20_parts_id']); $part_number = mysqli_real_escape_string($con, $_POST['part_number']); $discription = mysqli_real_escape_string($con, $_POST['description']); $location = mysqli_real_escape_string($con, $_POST['location']); $quantity = mysqli_real_escape_string($con, $_POST['quantity']); $sql="INSERT INTO amp_20 (amp_20_parts_id, part_number, description, location, quantity) VALUES ('$amp_20_parts_id', '$part_number', '$description', '$location', '$quantity')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); } ?> Hi, I'm working with sessions for the first time and have been able to put a member's id into the database. However, when I try and put their display name into the database I got a message saying Unknown column 'xyz' in 'field list' xyz was the display name for the session. Just can't seem to see what I'm doing wrong. In the code below, I even tried changing $_SESSION['member_display_name'] to $_SESSION['member_id'], in which case the correct id was inserted into both the member_id and the member_display_name fields in the database, so I know the table is set up correctly. Any tips? Code: [Select] //**********************SEND TO DATABASE**************************** include 'mysql_connect.php'; $query = "INSERT INTO uploads (date, member_id, upload_name, upload_title, upload_type, subject, topic, year, status, keywords, description, member_display_name, firstname, lastname)" . "VALUES (NOW(), ".$_SESSION['member_id'] . ",'$upload_nameX', '$upload_title', '".$EXPLODED_STRING[1]."', '$subject', '$topic', '$year', '$status', '$keywords', '$description', ".$_SESSION['member_display_name'] . ", '$firstname', '$lastname')"; //if($query){echo 'data has been placed'} mysql_query($query) or die(mysql_error()); $upload_id = mysql_insert_id(); //***********************END OF DATABASE CODE*********************** Hello all, I have a directory page that is populated with a foreach loop pulling info from a db table. I want to make a "Download Directory pdf" button that will print out the directory entries in a nicely formatted way. The thing is that the foreach loop uses an OO call to what every template is being used for the HTML display: foreach ( (array) $results as $row) { ... $out .= '<div class="cn-list-row' . $alternate . ' vcard ' . $template->slug . ' ' . $entry->getCategoryClass(TRUE) . '">' . "\n"; $out = apply_filters('cn_entry_before', $out, $entry); ob_start(); include($template->file); $out .= ob_get_contents(); ob_end_clean(); $out = apply_filters('cn_entry_after', $out, $entry); $out .= '</div>' . "\n"; } $out .= '<div class="clear"></div>' . "\n"; $out .= '</div>' . "\n"; $out = apply_filters('cn_list_after', $out, $results); return $out; } Any Ideas?? Well, I have been able to create a registration and login page. Now I am trying to make an "Edit Profile" page but I can't seem to be able to pull up their primary key field which is called "userID" and I need help doing this. How would I get it from the MySQL database? I'm currently trying...struggling....to teach myself PHP and I'm really bugged with this database stuff. I am slowly managing but I'm a tad bit stuck now. I want to show a specific piece of information from a table. Lets say my table is structured like so: id user email 1 Bob Bob@Name.com 2 Fred Fred@Name.com 3 Matt Matt@Name.com What would I need to do to display ONLY Freds user? One way I tried only displayed the first rows info (Bob) the second way I tried (with a while loop) only displayed the last rows info (Matt) Heres my current code: <html> <body> <?php include 'dbwire.php'; $query = mysql_query('SELECT * FROM user'); $row = mysql_fetch_array($query); while ($row = mysql_fetch_array($query)) { echo '<b>User:</b> ' . $row['user'] . '<br />'; } ?> </body> </html> if (($update_avatar1 == 'http://images.toxicpets.co.cc/vPets/Acara11.gif') OR ($update_avatar1 == 'http://images.toxicpets.co.cc/vPets/Aisha5.gif')) { mysql_query("UPDATE avatar SET avatar = '$update_avatar1' WHERE username = '$username' AND game = '$game'") or die ("Database error: ".mysql_error()); mysql_query("INSERT INTO avatar ($update_avatar1 WHERE id = '$userid')"); This is an avatar System But It Is Not Inserting Into The Database Hi. Am trying to make an install script but have run into a problem. ---- variables.php - holds the variables that I need install.php - connects to the database and inserts all the values. Now I have a problem. When I execute the install.php it outputs: Creating tables... Connected to database server Database webleague is selected Players table Games table News table Rules table Games table Vars table Inserting default values Inserting news Inserting rules Inserting themes Inserting vars Done. but doesnt insert ANYTHING into the database. Can anyone help? Variables.php: <?php //start //configure database info $databaseserver = "localhost"; //usually localhost $databasename = "xxxxxxxxx"; //the name of your database $databaseuser = "xxxxxxxxx"; //the name of the database user $databasepass = "xxxxxxxxx"; // the password to your database $directory ="http://xxxxxxxxxxxxxxxxxx" ; //the location of your WebLeague directory (no trailing slash) //configure the tables in the database $playerstable = "webl_players"; //the name of the table that contains information about the players $gamestable = "webl_games"; //the name of the table that stores the played games $newstable = "webl_news"; // the name of the table that stores the news $themestable = "webl_themes"; //the name of the table that stores the themes $varstable = "webl_vars"; //the name of the table that stores various information $rulestable = "webl_rules"; //the name of the table the stores the rules //set some general information on your league $leaguename = "IRC League"; //the name of your league $title = ".: IRC League :."; //the title of your pages $favicon = "$directory/WebLeaguefavicon.ico" ; //the location of the shortcut icon $report = "winner"; //who reports? winner/loser $pointswin = "3"; //the number of points awarded for a win $pointsloss = "-1"; //the number of points awarded for a loss //set the username and password for the admin panel $LOGIN = "xxxxxxxxxx"; //the username to access the admin panel $PASSWORD = "xxxxxxxxx"; //the passoword to access the admin panel // finish ?> And this is install.php: Creating tables...<br><br> <?php include "variables.php"; $db = mysql_connect($databaseserver, $databaseuser, $databasepass) or die("Connection Failure to Database Server"); echo "Connected to database server<br>"; mysql_select_db($databasename, $db) or die ($databasename . " Database not found." . $databaseuser); echo "Database " . $databasename . " is selected<br><br>"; if ($db==false) die("Failed to connect to MySQL server<br>\n"); $sql = "CREATE TABLE $playerstable (player_id int(10) DEFAULT '0' NOT NULL auto_increment, name varchar(40) DEFAULT '' NOT NULL, passworddb varchar(10), mail varchar(50), icq varchar(15), aim varchar (40), country varchar(40), games int(10) DEFAULT '0', wins int(10) DEFAULT '0', losses int(10) DEFAULT '0', points int(10) DEFAULT '0', totalwins int(10) DEFAULT '0', totallosses int(10) DEFAULT '0', totalpoints int(10) DEFAULT '0', totalgames int(10) DEFAULT '0', penalties int(10) DEFAULT '0', staff varchar(10), streakwins int(10) DEFAULT '0', streaklosses int(10) DEFAULT '0', PRIMARY KEY (player_id))"; mysql_query($sql,$db); $sql = "ALTER TABLE $playerstable ADD UNIQUE(name) "; mysql_query($sql,$db); echo"Players table<br>"; $sql = "CREATE TABLE $gamestable (game_id int(10) DEFAULT '0' NOT NULL auto_increment, winner varchar(40), loser varchar(40), date varchar(40), PRIMARY KEY (game_id))"; mysql_query($sql,$db); echo"Games table<br>"; $sql = "CREATE TABLE $newstable (news_id int(10) DEFAULT '0' NOT NULL auto_increment, news text, PRIMARY KEY (news_id))"; mysql_query($sql,$db); echo"News table<br>"; $sql = "CREATE TABLE $rulestable (rules_id int(10) DEFAULT '0' NOT NULL auto_increment, rules text, PRIMARY KEY (rules_id))"; mysql_query($sql,$db); echo"Rules table<br>"; $sql = "CREATE TABLE $themestable (theme_id int(10) DEFAULT '0' NOT NULL auto_increment, name varchar(40), color1 varchar(40), color2 varchar(40), color3 varchar(40), color4 varchar(40), aimthemepic varchar(80), bottomleftpic varchar(80), bottommiddlepic varchar(80), bottomrightpic varchar(80), headerbgpic varchar(80), headermenuleftpic varchar(80), headermenurightpic varchar(80), sideleftpic varchar(80), siderightpic varchar(80), topleftpic varchar(80), topmiddlepic varchar(80), toprightpic varchar(80), PRIMARY KEY (theme_id))"; mysql_query($sql,$db); echo"Games table<br>"; $sql = "CREATE TABLE $varstable (vars_id int(10) DEFAULT '0' NOT NULL auto_increment, theme varchar(20), font varchar(80), fontcolor varchar(40), headerfont varchar(80), numgamespage int(10), numplayerspage int (10), statsview varchar(10), stats1view varchar(10), stats2view varchar(10), stats3view varchar(10), stats4view varchar(10), stats5view varchar(10), stats6view varchar(10), stats7view varchar(10), statsnum int(10), rulesview varchar(10), standingsnogames varchar(10), pctnum varchar(10), hotcoldnum varchar(10), gamesmaxday int(10), PRIMARY KEY (vars_id))"; mysql_query($sql,$db); echo"Vars table<br><br>"; echo"Inserting default values<br>"; $sql = "INSERT INTO $newstable (news) VALUES ('Welcome to WebLeague<br><br>WebLeague is an automated league system, that makes organizing an online league a piece of cake.<br><br>To put your own news here, go to the news section in your admin panel<br><br>Have fun using WebLeague')"; mysql_query($sql,$db); echo"Inserting news<br>"; $sql = "INSERT INTO $rulestable (rules) VALUES ('Insert your rules by going to the rules section in the admin panel')"; mysql_query($sql,$db); echo"Inserting rules<br>"; $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('blue','#0080FF','#000066', '#FFFFFF', '#000099', '/themes/blue/aim.jpg', '/themes/blue/bottomleft.jpg', '/themes/blue/bottommiddle.jpg', '/themes/blue/bottomright.jpg', '/themes/blue/headerbg.jpg', '/themes/blue/headermenuleft.jpg', '/themes/blue/headermenuright.jpg', '/themes/blue/sideleft.jpg', '/themes/blue/sideright.jpg', '/themes/blue/topleft.jpg', '/themes/blue/topmiddle.jpg', '/themes/blue/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('blue2','#66809A','#29293D', '#FFFFFF', '#444466', '/themes/blue2/aim.jpg', '/themes/blue2/bottomleft.jpg', '/themes/blue2/bottommiddle.jpg', '/themes/blue2/bottomright.jpg', '/themes/blue2/headerbg.jpg', '/themes/blue2/headermenuleft.jpg', '/themes/blue2/headermenuright.jpg', '/themes/blue2/sideleft.jpg', '/themes/blue2/sideright.jpg', '/themes/blue2/topleft.jpg', '/themes/blue2/topmiddle.jpg', '/themes/blue2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('red','#FF0000','#660000', '#FFFFFF', '#990000', '/themes/red/aim.jpg', '/themes/red/bottomleft.jpg', '/themes/red/bottommiddle.jpg', '/themes/red/bottomright.jpg', '/themes/red/headerbg.jpg', '/themes/red/headermenuleft.jpg', '/themes/red/headermenuright.jpg', '/themes/red/sideleft.jpg', '/themes/red/sideright.jpg', '/themes/red/topleft.jpg', '/themes/red/topmiddle.jpg', '/themes/red/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('red2','#9A666C','#3D2929', '#FFFFFF', '#664444', '/themes/red2/aim.jpg', '/themes/red2/bottomleft.jpg', '/themes/red2/bottommiddle.jpg', '/themes/red2/bottomright.jpg', '/themes/red2/headerbg.jpg', '/themes/red2/headermenuleft.jpg', '/themes/red2/headermenuright.jpg', '/themes/red2/sideleft.jpg', '/themes/red2/sideright.jpg', '/themes/red2/topleft.jpg', '/themes/red2/topmiddle.jpg', '/themes/red2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('green','#00FF00','#006600', '#FFFFFF', '#009900', '/themes/green/aim.jpg', '/themes/green/bottomleft.jpg', '/themes/green/bottommiddle.jpg', '/themes/green/bottomright.jpg', '/themes/green/headerbg.jpg', '/themes/green/headermenuleft.jpg', '/themes/green/headermenuright.jpg', '/themes/green/sideleft.jpg', '/themes/green/sideright.jpg', '/themes/green/topleft.jpg', '/themes/green/topmiddle.jpg', '/themes/green/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('green2','#6C9A66','#2D3D29', '#FFFFFF', '#446644', '/themes/green2/aim.jpg', '/themes/green2/bottomleft.jpg', '/themes/green2/bottommiddle.jpg', '/themes/green2/bottomright.jpg', '/themes/green2/headerbg.jpg', '/themes/green2/headermenuleft.jpg', '/themes/green2/headermenuright.jpg', '/themes/green2/sideleft.jpg', '/themes/green2/sideright.jpg', '/themes/green2/topleft.jpg', '/themes/green2/topmiddle.jpg', '/themes/green2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('orange','#FF8000','#662200', '#FFFFFF', '#994000', '/themes/orange/aim.jpg', '/themes/orange/bottomleft.jpg', '/themes/orange/bottommiddle.jpg', '/themes/orange/bottomright.jpg', '/themes/orange/headerbg.jpg', '/themes/orange/headermenuleft.jpg', '/themes/orange/headermenuright.jpg', '/themes/orange/sideleft.jpg', '/themes/orange/sideright.jpg', '/themes/orange/topleft.jpg', '/themes/orange/topmiddle.jpg', '/themes/orange/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('orange2','#9A7E66','#3D3129', '#FFFFFF', '#664444', '/themes/orange2/aim.jpg', '/themes/orange2/bottomleft.jpg', '/themes/orange2/bottommiddle.jpg', '/themes/orange2/bottomright.jpg', '/themes/orange2/headerbg.jpg', '/themes/orange2/headermenuleft.jpg', '/themes/orange2/headermenuright.jpg', '/themes/orange2/sideleft.jpg', '/themes/orange2/sideright.jpg', '/themes/orange2/topleft.jpg', '/themes/orange2/topmiddle.jpg', '/themes/orange2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('purple','#9900FF','#330066', '#FFFFFF', '#660099', '/themes/purple/aim.jpg', '/themes/purple/bottomleft.jpg', '/themes/purple/bottommiddle.jpg', '/themes/purple/bottomright.jpg', '/themes/purple/headerbg.jpg', '/themes/purple/headermenuleft.jpg', '/themes/purple/headermenuright.jpg', '/themes/purple/sideleft.jpg', '/themes/purple/sideright.jpg', '/themes/purple/topleft.jpg', '/themes/purple/topmiddle.jpg', '/themes/purple/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('purple2','#83669A','#32293D', '#FFFFFF', '#664466', '/themes/purple2/aim.jpg', '/themes/purple2/bottomleft.jpg', '/themes/purple2/bottommiddle.jpg', '/themes/purple2/bottomright.jpg', '/themes/purple2/headerbg.jpg', '/themes/purple2/headermenuleft.jpg', '/themes/purple2/headermenuright.jpg', '/themes/purple2/sideleft.jpg', '/themes/purple2/sideright.jpg', '/themes/purple2/topleft.jpg', '/themes/purple2/topmiddle.jpg', '/themes/purple2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('black','#666666','#000000', '#FFFFFF', '#999999', '/themes/black/aim.jpg', '/themes/black/bottomleft.jpg', '/themes/black/bottommiddle.jpg', '/themes/black/bottomright.jpg', '/themes/black/headerbg.jpg', '/themes/black/headermenuleft.jpg', '/themes/black/headermenuright.jpg', '/themes/black/sideleft.jpg', '/themes/black/sideright.jpg', '/themes/black/topleft.jpg', '/themes/black/topmiddle.jpg', '/themes/black/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('yellow','#FFEF00','#635200', '#FFFFFF', '#999900', '/themes/yellow/aim.jpg', '/themes/yellow/bottomleft.jpg', '/themes/yellow/bottommiddle.jpg', '/themes/yellow/bottomright.jpg', '/themes/yellow/headerbg.jpg', '/themes/yellow/headermenuleft.jpg', '/themes/yellow/headermenuright.jpg', '/themes/yellow/sideleft.jpg', '/themes/yellow/sideright.jpg', '/themes/yellow/topleft.jpg', '/themes/yellow/topmiddle.jpg', '/themes/yellow/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('yellow2','#9A9666','#3D3A29', '#FFFFFF', '#666644', '/themes/yellow2/aim.jpg', '/themes/yellow2/bottomleft.jpg', '/themes/yellow2/bottommiddle.jpg', '/themes/yellow2/bottomright.jpg', '/themes/yellow2/headerbg.jpg', '/themes/yellow2/headermenuleft.jpg', '/themes/yellow2/headermenuright.jpg', '/themes/yellow2/sideleft.jpg', '/themes/yellow2/sideright.jpg', '/themes/yellow2/topleft.jpg', '/themes/yellow2/topmiddle.jpg', '/themes/yellow2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('pink','#FF00EF','#660066', '#FFFFFF', '#990099', '/themes/pink/aim.jpg', '/themes/pink/bottomleft.jpg', '/themes/pink/bottommiddle.jpg', '/themes/pink/bottomright.jpg', '/themes/pink/headerbg.jpg', '/themes/pink/headermenuleft.jpg', '/themes/pink/headermenuright.jpg', '/themes/pink/sideleft.jpg', '/themes/pink/sideright.jpg', '/themes/pink/topleft.jpg', '/themes/pink/topmiddle.jpg', '/themes/pink/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('pink2','#9A6696','#3C293D', '#FFFFFF', '#664466', '/themes/pink2/aim.jpg', '/themes/pink2/bottomleft.jpg', '/themes/pink2/bottommiddle.jpg', '/themes/pink2/bottomright.jpg', '/themes/pink2/headerbg.jpg', '/themes/pink2/headermenuleft.jpg', '/themes/pink2/headermenuright.jpg', '/themes/pink2/sideleft.jpg', '/themes/pink2/sideright.jpg', '/themes/pink2/topleft.jpg', '/themes/pink2/topmiddle.jpg', '/themes/pink2/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('greenblue','#00FFEA','#006654', '#FFFFFF', '#009999', '/themes/greenblue/aim.jpg', '/themes/greenblue/bottomleft.jpg', '/themes/greenblue/bottommiddle.jpg', '/themes/greenblue/bottomright.jpg', '/themes/greenblue/headerbg.jpg', '/themes/greenblue/headermenuleft.jpg', '/themes/greenblue/headermenuright.jpg', '/themes/greenblue/sideleft.jpg', '/themes/greenblue/sideright.jpg', '/themes/greenblue/topleft.jpg', '/themes/greenblue/topmiddle.jpg', '/themes/greenblue/topright.jpg')"; mysql_query($sql,$db); $sql = "INSERT INTO $themestable (name, color1, color2, color3, color4, aimthemepic, bottomleftpic, bottommiddlepic, bottomrightpic, headerbgpic, headermenuleftpic, headermenurightpic, sideleftpic, siderightpic, topleftpic, topmiddlepic, toprightpic) VALUES ('greenblue2','#679B97','#293D39', '#FFFFFF', '#446666', '/themes/greenblue2/aim.jpg', '/themes/greenblue2/bottomleft.jpg', '/themes/greenblue2/bottommiddle.jpg', '/themes/greenblue2/bottomright.jpg', '/themes/greenblue2/headerbg.jpg', '/themes/greenblue2/headermenuleft.jpg', '/themes/greenblue2/headermenuright.jpg', '/themes/greenblue2/sideleft.jpg', '/themes/greenblue2/sideright.jpg', '/themes/greenblue2/topleft.jpg', '/themes/greenblue2/topmiddle.jpg', '/themes/greenblue2/topright.jpg')"; mysql_query($sql,$db); echo"Inserting themes<br>"; $sql = "INSERT INTO $varstable (theme, font, fontcolor, headerfont, numgamespage, numplayerspage, statsview, stats1view, stats2view, stats3view, stats4view, stats5view, stats6view, stats7view, statsnum, rulesview, standingsnogames, pctnum, hotcoldnum, gamesmaxday) VALUES ('blue','Arial', '#FFFFFF', 'Arial Black', '20', '30', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', '10', 'yes', 'no', '10', '5', '2')"; mysql_query($sql,$db); echo"Inserting vars<br><br>"; echo"Done."; ?> Once again... it says its done when i execute the code in the browser but is not inserting anything into my database. Weird... Hi guys..... I'm having a problem that I've been tearing my hair out over for way too long. I'm hoping that some of you may be able to help me or at least point me in the right direction. I'm using MySQL 5.0.91 (via PHPmyAdmin from GoDaddy). This query should basically grab the data from the Facebook API and insert it into the database. It's not doing that. After inserting the data, it queries the database, and redirects the user to their profile page (USERNAME.php). Because there is no data in the database for that user, it has no idea what their username is, so it redirects them to ".php"....yes, that is "[dot]php". I'm not entirely sure how to debug this either. I've tried a few var_dump()'s with not much luck. Is there a specific order in which this stuff needs to be in? Maybe that's the problem, so I'm also including a screenshot from PHPmyAdmin of the database table. Here's the code: // user not in db, insert details if(!empty($user)){ $apiGet = array( 'method' => 'users.getinfo', 'uids' => $uid, 'fields' => 'uid, name, first_name, last_name, pic_square, pic_big, sex, email, birthday_date, activities, interests, status, about_me' //theses are the fields it pulls from the Facebook API ); // create array to hold returned values $fbi = $facebook->api($apiGet); // insert details $iString = "oauth_provider, oauth_uid, username, name, first_name, last_name, sex, pic_big, email, joined, lastLogon, birthday_date, user_activities, user_interests, user_status, user_about_me"; $iArray = array(); //the following are the values of the fields array_push($iArray,'facebook'); array_push($iArray,$user['id']); array_push($iArray,$user['name']); array_push($iArray,$fbi[0]['name']); array_push($iArray,$fbi[0]['first_name']); array_push($iArray,$fbi[0]['last_name']); array_push($iArray,$fbi[0]['sex']); array_push($iArray,$fbi[0]['pic_big']); array_push($iArray,$fbi[0]['email']); array_push($iArray,time()); array_push($iArray,time()); array_push($iArray,$fbi[0]['birthday_date']); array_push($iArray,$fbi[0]['user_activities']); array_push($iArray,$fbi[0]['user_interests']); array_push($iArray,$fbi[0]['user_status']); array_push($iArray,$fbi[0]['user_about_me']); var_dump($email); $db->insert('users',$iArray,$iString); $where = "oauth_uid = '{$uid}'"; $db->select('*','users',$where); $result = $db->getResult(); // the next line creates a profile page. After that, there are lines that point the user to that page. createProfile($result['username']); I've added some comments to it to articulate what is going on. Thanks in advance! Alex Hi Im having some trouble implementing info into a database Sir/ma'am,
With the script I'm using to run my website, I've been trying to add an additional feature for the users to add/edit. I'll try to provide as much info as I can, hopefully it'll help.
Here is the code I'm using to display the user's unique info from the db.
<a class="wallet-edit"><?php echo $_SESSION['simple_auth']['INFO']?></a>That displays the user's info from the column 'INFO' perfectly. It's also a js popup to a menu to where I'm hoping to add a single textbox to edit the INFO. The script uses a similar function to edit the password with a popup. I've tried modifying the code to edit the INFO column but it doesn't work. Here is the default code it has to edit the password. I'm not sure if it can be changed to edit another column or needs a new piece of code for that. // user edit $('body').on('click', '.username-edit', function() { $('#modal').html(' '); var output = '<div class="modal-content"><h5><?php echo lang::get("Change password")?></h5><hr />'; output += '<h5><?php echo lang::get("New password:")?></h5><input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />'; output += '<h5><?php echo lang::get("Confirm password:")?></h5><input type="password" name="password2" id="password2" value="" class="text ui-widget-content ui-corner-all" />'; output += '</div>'; output += '<div class="modal-buttons right">'; output += '<button id="confirm-button" type="button" class="nice radius button"><?php echo lang::get("Change")?></button>'; output += '</div>'; output += '<a class="close-reveal-modal"></a>'; $('#modal').append(output); $('#second_modal').hide(); $('#modal').reveal(); $('#confirm-button').click(function(){ $('#password').css('border-color', '#CCCCCC'); $('#password2').css('border-color', '#CCCCCC'); var password = $('#password').val(); var password2 = $('#password2').val(); if(typeof(password) === 'undefined' || password == ''){ $('#password').css('border-color', 'red'); return false; } if(password != password2){ $('#password2').css('border-color', 'red'); return false; } password_data = encodeURIComponent(password); $.post("<?php echo gatorconf::get('base_url')?>", { changepassword: password_data} ).done(function(data) { // flush window.location.href = '<?php echo gatorconf::get('base_url')?>'; }); }); });If the code above can be edited to work with what I'm trying to do, it of course only needs one textbox and doesn't have to be confirmed by a second input. Please help! Thanks! Hey all Im working on an assignment for school and currently I am trying to inser the variable $uid which currently = 2.. But for someone reason when the post happens it inserts a 0 instead of a 2. Here is my insert Code: [Select] mysql_query( "INSERT INTO blog_posts (title, post, author_id, date_posted) ". "VALUES ('$btitle', '$bpost', '$uid', CURDATE())" ); |