PHP - Insert Php Table Code In Tpl File
Hello,
i have this php code. Its for sms insertion of links in to table <table border="1"> <?PHP $db_user = 'user'; $db_pass = 'pass'; $db_name = 'name'; $db_host = 'localhost'; if(mysql_connect($db_host,$db_user,$db_pass)) { mysql_select_db($db_name); mysql_query("CREATE TABLE IF NOT EXISTS smsads(id bigint unsigned primary key auto_increment, link varchar(255), fromnum varchar(60))"); $res = mysql_query("SELECT * FROM smsads ORDER BY id DESC LIMIT 10"); while($row = mysql_fetch_object($res)) { $http_link = $row->link; if(strstr($http_link, 'http') === FALSE) $http_link = 'http://'.$http_link; echo "<tr><td><a href=\"{$http_link}\" target=\"_blank\">{$row->link}</a></td></tr>"; } } ?> </table> The problem is that i use tpl files for the visual part and all my other tables are in tpl. How can i insert the table above in my tpl file, whitout loosing its functions? Similar TutorialsI am very new to PHP and haven't wriiten an update program except in the class I took about 4 years ago using MYSQL.
The company I work for is using PDO so I am having a little bit of a learning curve.
I have a table with a checkbox at the end and I want to insert the records from the table into a new file I created called
OPPSHEDT
SHEDORD Order Number 14 Char
SHEDBORD BackOrder Number 2 Char
SHEDPKD Picked Cases 9,0 Decimal
SHEDSHP Shipped Cases 9,0 Decimal
I'm just not sure how to write the update program to read the array of records and run through the loop and insert the items checked. I saw some other examples on here and all over the internet but they were using mysql. I have a copy of the code to create my table below.
I'd appreciate the help if you can.
Thanks.
ShipEstimate.php 6.41KB
4 downloads
I'd like to write - or acquire - code that displays a simple table (name, phone number, email address, plus a comments field) on a web page in a password-protected page and allows a user to add his own information, update it or delete it. I figure hundreds of people and companies have written something like this so I'd like to find either an example I can imitate or even an existing package that I can simply customize to the specifics for my own table. Can anyone help me with that? Or am I going to have to reinvent the wheel for the gazillionth time and write it myself? Hi, I need to insert some code into my current form code which will check to see if a username exist and if so will display an echo message. If it does not exist will post the form (assuming everything else is filled in correctly). I have tried some code in a few places but it doesn't work correctly as I get the username message exist no matter what. I think I am inserting the code into the wrong area, so need assistance as to how to incorporate the username check code. $sql="select * from Profile where username = '$username'; $result = mysql_query( $sql, $conn ) or die( "ERR: SQL 1" ); if(mysql_num_rows($result)!=0) { process form } else { echo "That username already exist!"; } the current code of the form <?PHP //session_start(); require_once "formvalidator.php"; $show_form=true; if (!isset($_POST['Submit'])) { $human_number1 = rand(1, 12); $human_number2 = rand(1, 38); $human_answer = $human_number1 + $human_number2; $_SESSION['check_answer'] = $human_answer; } if(isset($_POST['Submit'])) { if (!isset($_SESSION['check_answer'])) { echo "<p>Error: Answer session not set</p>"; } if($_POST['math'] != $_SESSION['check_answer']) { echo "<p>You did not pass the human check.</p>"; exit(); } $validator = new FormValidator(); $validator->addValidation("FirstName","req","Please fill in FirstName"); $validator->addValidation("LastName","req","Please fill in LastName"); $validator->addValidation("UserName","req","Please fill in UserName"); $validator->addValidation("Password","req","Please fill in a Password"); $validator->addValidation("Password2","req","Please re-enter your password"); $validator->addValidation("Password2","eqelmnt=Password","Your passwords do not match!"); $validator->addValidation("email","email","The input for Email should be a valid email value"); $validator->addValidation("email","req","Please fill in Email"); $validator->addValidation("Zip","req","Please fill in your Zip Code"); $validator->addValidation("Security","req","Please fill in your Security Question"); $validator->addValidation("Security2","req","Please fill in your Security Answer"); if($validator->ValidateForm()) { $con = mysql_connect("localhost","uname","pw") or die('Could not connect: ' . mysql_error()); mysql_select_db("beatthis_beatthis") or die(mysql_error()); $FirstName=mysql_real_escape_string($_POST['FirstName']); //This value has to be the same as in the HTML form file $LastName=mysql_real_escape_string($_POST['LastName']); //This value has to be the same as in the HTML form file $UserName=mysql_real_escape_string($_POST['UserName']); //This value has to be the same as in the HTML form file $Password= md5($_POST['Password']); //This value has to be the same as in the HTML form file $Password2= md5($_POST['Password2']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file $Zip=mysql_real_escape_string($_POST['Zip']); //This value has to be the same as in the HTML form file $Birthday=mysql_real_escape_string($_POST['Birthday']); //This value has to be the same as in the HTML form file $Security=mysql_real_escape_string($_POST['Security']); //This value has to be the same as in the HTML form file $Security2=mysql_real_escape_string($_POST['Security2']); //This value has to be the same as in the HTML form file $sql="INSERT INTO Profile (`FirstName`,`LastName`,`Username`,`Password`,`Password2`,`email`,`Zip`,`Birthday`,`Security`,`Security2`) VALUES ('$FirstName','$LastName','$UserName','$Password','$Password2','$email','$Zip','$Birthday','$Security','$Security2')"; //echo $sql; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else{ mail('email@gmail.com','A profile has been submitted!',$FirstName.' has submitted their profile',$body); echo "<h3>Your profile information has been submitted successfully.</h3>"; } mysql_close($con); $show_form=false; } else { echo "<h3 class='ErrorTitle'>Validation Errors:</h3>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p class='errors'>$inpname : $inp_err</p>\n"; } } } if(true == $show_form) { ?> Hi
I am very new to PHP & Mysql.
I am trying to insert values into two tables at the same time. One table will insert a single row and the other table will insert multiple records based on user insertion.
Everything is working well, but in my second table, 1st Table ID simply insert one time and rest of the values are inserting from 2nd table itself.
Now I want to insert the first table's ID Field value (auto-incrementing) to a specific column in the second table (only all last inserted rows).
Ripon.
Below is my Code:
<?php $con = mysql_connect("localhost","root","aaa"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ccc", $con); $PI_No = $_POST['PI_No']; $PO_No = $_POST['PO_No']; $qry = "INSERT INTO wm_order_entry ( Order_No, PI_No, PO_No) VALUES( NULL, '$PI_No', '$PO_No')"; $result = @mysql_query($qry); $val1=$_POST['Size']; $val2=$_POST['Style']; $val3=$_POST['Colour']; $val4=$_POST['Season_Code']; $val5=$_POST['Dept']; $val6=$_POST['Sub_Item']; $val7=$_POST['Item_Desc']; $val8=$_POST['UPC']; $val9=$_POST['Qty']; $N = count($val1); for($i=0; $i < $N; $i++) { $profile_query = "INSERT INTO order_entry(Size, Style, Colour, Season_Code, Dept, Sub_Item, Item_Desc, UPC, Qty, Order_No ) VALUES( '$val1[$i]','$val2[$i]','$val3[$i]','$val4[$i]','$val5[$i]','$val6[$i]','$val7[$i]','$val8[$i]','$val9[$i]',LAST_INSERT_ID())"; $t_query=mysql_query($profile_query); } header("location: WMView.php"); mysql_close($con); ?>Output is attached. I use this type of a code to send automatic emails from my website: Code: [Select] $headers = ; $headers .= ; $to = ; Click here to go to Google. ", $headers); I am having hard time figuring out how to do hyperlink on words (like here). If I do something like this: Code: [Select] <a href='http://www.google.com'>here</a> it spits out that exact thing out. Thanks you for your input files that upload during insert/submit form was gone , only files upload during the update remain , is the way query for update multiple files is wrong ? $targetDir1= "folder/pda-semakan/ic/"; if(isset($_FILES['ic'])){ $fileName1 = $_FILES['ic']['name']; $targetFilePath1 = $targetDir1 . $fileName1; //$main_tmp2 = $_FILES['ic']['tmp_name']; $move2 =move_uploaded_file($_FILES["ic"]["tmp_name"], $targetFilePath1); } $targetDir2= "folder/pda-semakan/sijil_lahir/"; if(isset($_FILES['sijilkelahiran'])){ $fileName2 = $_FILES['sijilkelahiran']['name']; $targetFilePath2 = $targetDir2 . $fileName2; $move3 =move_uploaded_file($_FILES["sijilkelahiran"]["tmp_name"], $targetFilePath2); } $targetDir3= "folder/pda-semakan/sijil_spm/"; if(isset($_FILES['sijilspm'])){ $fileName3 = $_FILES['sijilspm']['name']; $targetFilePath3 = $targetDir3 . $fileName3; $move4 =move_uploaded_file($_FILES["sijilspm"]["tmp_name"], $targetFilePath3); } $query1=("UPDATE semakan_dokumen set student_id='$noMatrik', email= '$stdEmail', surat_tawaran='$fileName', ic='$fileName1',sijil_lahir='$fileName2',sijil_spm= '$fileName3' where email= '$stdEmail'");
Thanks ahead of time, I have been working this all week end but get lost.... a. I want to insert all the lines from file1.txt into file2.txt . b. I want the all lines in file1.txt to be inserted in file2.txt starting at "<image>" tag label in file2.txt. c. I would like to overwrite all lines that start with the "<image>" tag in file2.txt with the insert (text in file1.txt contains <image> tag also). file2.txt has lines above and below the insert point <image>. The insert text (file1.txt) could be as many as twenty lines (records) all/each beginning with the<image>tag. Here is what I have done so far. <? $key = '<image>'; //a text tag in $file1 and $file2 //copy file $file = "file1.txt"; $file2= 'file2.txt"; $newfile = "filetemp.txt"; copy($file, $newfile) or exit("could not copy $file"); //load file array $fc = fopen ($file, "r"); while (!feof ($fc)) { $buffer = fgets($fc, 4096); $lines[] = $buffer; } fclose ($fc); //open same file and use "w" to clear file ,not sure this is needed $f=fopen($newfile,"w") or die("$file did not open"); /* uncomment to debug print_r($lines); print "<br>\n"; */ //loop through array 'foreach foreach($lines as $line) { fwrite($f,$line); //rewrite $line in file if (strstr($line,$key)){ //find $key in each line fwrite($f,$newline."\n"); } //rewrite $line in file } fclose($f); copy($newfile, $file2) or exit("could not copy $newfile"); ?> Again thanks ahead of time, I just keep losing the flow, old I guess. Tom I've Basically got this script and everything works. Except for the part that it doesen't insert "$_FILES['file']['name']" into the image_url. Any Ideas guys? Code: [Select] <? include "includes/config.php"; if (isset($_POST['add'])) { if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists("images/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; echo $_FILES['file']['name']; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "images/" . $_FILES["file"]["name"]); } } } else { echo "Sorry, but only PNG, JPG, and GIF files are allowed."; } mysql_connect ($mysql_host, $mysql_user, $mysql_pass); mysql_select_db ($mysql_db); $image_url = "http://localhost/admin/images/". $_FILES['file']['name'] .""; $sql = "INSERT INTO test (title, link, description, image_url) VALUES ('$_POST[title]', '$_POST[link]', '$_POST[description]', '$image_url')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } header( 'Location: portfolio.php' ); mysql_close(); } ?> Code: [Select] <form enctype="multipart/form-data" method="post"> <p> <strong>TITLE</strong><br/> <input type="text" name="title" class="box"/> </p> <p> <strong>LINK</strong><br/> <input type="text" name="link" class="box"/> </p> <p> <strong>IMAGE</strong><br/> <input type="file" class="box" name="file"/> </p> <p> <strong>DESCRIPTION</strong><br/> <input type="textarea" name="description" class="box"/> </p> <p> <input name="add" type="submit" id="submit" tabindex="5" class="com_btn" value="ADD WORK"/> </p> </form> I want to limit the length of an author's name in a display to 10 characters - using two lines if necessary for full display. I know I can use wordwrap of some sort to do that. However, I am not sure where/how to accomplish it. Can it be inserted in the following (and if so, where/what do I insert, specifically): Code: [Select] <?php _e('Order by','authors') ?>:<br /> <label for="authors-order-<?php echo $number; ?>-name"><input type="radio" class="radio" id="authors-order-<?php echo $number; ?>-name" name="widget-authors[<?php echo $number; ?>][order]" value="name"<?php echo 'name' == $order || '' == $order ? ' checked="checked"' : '' ?> /> <?php _e('Display name','authors' ) ?></label> NOTE: I have attached the full code in a text file if I've selected the wrong snip. Thank you! [attachment deleted by admin] <?php require_once("../includes/session.php");?> <?php require_once("../includes/connection.php");?> <?php require_once("../includes/function.php");?> <?php confirm_logged_in();?> <?php require_once("../includes/validation_functions.php");?> <?php if(isset($_POST['submit'])){ //process the form // often there are form values in $_POST $product_name = mysql_prep($_POST["product_name"]); $product_amount = (int) $_POST["product_amount"]; $visible = (int) $_POST["visible"]; foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){ $file_tmp =$_FILES['files']['tmp_name'][$key]; $uploaded_dir = "images/"; $filename = $_FILES['files']['name'][$key]; $path = $uploaded_dir . $filename; move_uploaded_file($file_tmp,"images/".$_FILES['files']['name'][$key]); $query ="INSERT INTO products ("; $query .=" name, amount, visible"; $query .=") VALUES ("; $query .=" '{$product_name}',{$product_amount},{$visible}"; $query .=")"; $result = mysqli_query($connection,$query); $last_id = mysqli_insert_id($connection); $sql.= "('$last_id','$path'),"; $sql ="INSERT INTO images ( productID, file_name ) VALUES". trim($sql,','); $results = mysqli_query($connection,$sql); // validations $required_fields = array("product_name", "product_amount"); validate_presences($required_fields); $fields_with_max_lenghts = array("product_name" => 30); validate_max_lenght($fields_with_max_lenghts); if(!empty($errors)){ $_SESSION["errors"] = $errors; redirect_to("new_product.php"); } if($result && $results ){ // Sucess $_SESSION["message"] = "Product inserted."; redirect_to("manage_content.php"); }else{ // Failure $_SESSION["message"] = "Product insertion Failed."; redirect_to("new_product.php"); } } }else{ // THis is probably a GET request redirect_to("new_product.php"); } ?> <?php if(isset($connnection)){ mysqli_close($connection); } ?>Attached Files new_product.php 1.35KB 0 downloads create_product.php 1.99KB 0 downloads Hi, I am trying to insert the contents of a csv file into a table, this is my code: public function InsertCSVFileToDB(){ $has_title_row = true; $not_done = array(); if(is_uploaded_file($_FILES['csvfile']['tmp_name'])){ $filename = basename($_FILES['csvfile']['name']); if(substr($filename, -3) == 'csv'){ $tmpfile = $_FILES['csvfile']['tmp_name']; if (($fh = fopen($tmpfile, "r")) !== FALSE) { $i = 0; while (($items = fgetcsv($fh, 10000, ",")) !== FALSE) { if($has_title_row === true && $i == 0){ // skip the first row if there is a tile row in CSV file $i++; continue; } $sql = "INSERT INTO ConfPaper SET CPRid = ".$items[0].", Pid = ".$items[1].", CPtitle = '".mysql_real_escape_string($items[2])."', CPabstract = '".mysql_real_escape_string($items[3])."', CPspage = ".mysql_real_escape_string($items[4]).", CPepage = ".mysql_real_escape_string($items[5]).", CPlastesited = now()"; if(!mysql_query($sql)){ $not_done[] = $items; } $i++; } } // if there are any not done records found: if(!empty($not_done)){ echo "<strong>There are some records could not be inserted</strong><br />"; print_r($not_done); } } else{ die('Invalid file format uploaded. Please upload CSV.'); } } else{ die('Please upload a CSV file.'); } } This is the csv file: http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/ConfPaper.csv But i keep getting this: Quote Array ( => Array ( => 9 [1] => 1 [2] => CSV1 [3] => 4 [4] => 4 [5] => 01625 584412 ) [1] => Array ( => 9 [1] => 1 [2] => CSV2 [3] => 14 [4] => 24 [5] => 01625 584412 ) ) Any ideas what the problem might be? Hope someone can help.. Thanks hello, anybody able to see what im doing wrong? Code: [Select] $id2=mysql_insert_id(); $year=$_POST['y']; $yr=substr($year,-2); $mth=$_POST['m']; $init=$_POST['initial']; $jobnumber=$yr.$mth.'-'.$id2.$init; $query = "INSERT INTO jobs VALUES ( '', '$id2', '$_POST[initial]', '$_POST[y]-$_POST[m]-$_POST[d]',date '$_POST[contact]', '$_POST[contactphone]', '$_POST[customer]', '$_POST[address]', '$_POST[city]', '$_POST[postal]', '$_POST[province]', '$_POST[description]' )"; mysql_query($query) or die('Error, adding new job failed. Check you fields and try again.'); echo "You have successfully entered a new job. The job number is $jobnumber"; Hey guys, it seems that so far in my little script everything is working except for the MySQL insert Nothing seems to appear in the table it's supposed to insert too but i dont see any errors anywhere. Any help would be appreciated. I know it's very messy but it's my first actual 'project' Code: [Select] <?php $apiKey="<omitted>"; $playeritemsURL="http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/"; $fullURL=$playeritemsURL."?key=".$apiKey."&SteamID=".$_GET["SteamID64"]."&format=xml"; $playerLocalName=$_GET["SteamID64"].".xml"; $ch=curl_init($fullURL); $fh=fopen($playerLocalName, 'w'); ?> You entered ID: <?php echo $_GET["SteamID64"];?></br> <?php echo $fullURL; curl_setopt($ch,CURLOPT_FILE,$fh); curl_exec($ch); curl_close($ch); ?> </br> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("csv_db", $con); $readXML=file_get_contents($playerLocalName); $xml=simplexml_load_file($playerLocalName); $output=$_GET["SteamID64"].".defindex.txt"; $fh=fopen($output, 'w') or die("can't open file"); //echo $xml->items->item->defindex[0]; foreach ($xml->xpath('//defindex') as $defindex) { fwrite($fh, $defindex."\n"); echo $defindex."</br>"; mysql_query("INSERT INTO ".$_GET["SteamID64"]." (defindex) VALUES (".$defindex.")"); } ?> Hello guys, this is my first post so sorry if I made any mistake
I need select record from one table and move to another table
But I get this message saying "Warning: mysqli_query() expects at least 2 parameters, 1 given in" I had that on line 158, but now i get on line 156
I start to do PHP and mysql few weeks ago, only respond i get from teacher is search and search.
<?php if (isset($_POST['username'])) { $searchq = $_POST['username']; mysqli_query("SELECT * FROM login WHERE username='$searchq'")or die ("could not search"); while($row = mysqli_fetch_array($con, $query)) { $username = $row['username']; $password = $row['password']; $age = $row['age']; $phonenumber = $row['phonenumber']; $nationality = $row['nationality']; mysqli_query("INSERT INTO admin SET username ='$username', password='$password', age='$age', phonenumber='$phonenumber', nationality='$nationality'" ) ; echo"Data successfully inserted"; } } ?>When i search i see this type of code "$data = mysqli_query" add variable before mysqli What should I do, to make it work. And send record from one table to another. Thank you Hi there, I have a form which I want to submit data into my tables. There are going to be 4 tables involved with this form, and these 4 tables should relate to one another in some sort of way. My problem is either PHP or MySQL, but I keep getting a warning which I can't figure out. I remember this warning appearing even if the code before it is wrong, therefore I am not relying on it. This is what the error says: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in G:\xampp\htdocs\xampp\dsa\wp3.php on line 40 Here's my code: Code: [Select] <html> <head> <title>WP3</title> </head> <body> <form id="search" name="search" id="search" method="get" action="searchresults.php" /> <input type="text" name="terms" value="Search..." /> <input class="button" type="submit" name="Search" value="Search" /> </form> <?php include_once('connectvars.php'); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if(isset($_POST['report'])){ $firstname = mysqli_real_escape_string($dbc, trim($_POST['firstName'])); $middlename = mysqli_real_escape_string($dbc, trim($_POST['middleName'])); $lastname = mysqli_real_escape_string($dbc, trim($_POST['lastName'])); $image = mysqli_real_escape_string($dbc, trim($_POST['image'])); $phone = mysqli_real_escape_string($dbc, trim($_POST['phone'])); $organisation = mysqli_real_escape_string($dbc, trim($_POST['organisation'])); $street = mysqli_real_escape_string($dbc, trim($_POST['street'])); $town = mysqli_real_escape_string($dbc, trim($_POST['town'])); $city = mysqli_real_escape_string($dbc, trim($_POST['city'])); if (!empty($firstname) && !empty($middlename) && !empty($lastname) && !empty($image) && !empty($phone) && !empty($organisation) && !empty($city)) { $query = "INSERT INTO report (organisation, phoneNo) VALUES ('$organisation', '$phone'); INSERT INTO person (firstName, middleName, lastName) VALUES ('$firstname', '$middlename', '$lastname'); INSERT INTO identification (image) VALUES ('$image'); INSERT INTO location (street, town, city) VALUES ('$street', '$town', '$city')"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { mysqli_query($dbc, $query); echo "Thank you, your report has been received."; } else { // An account already exists for this username, so display an error message echo '<p>This report already exists.</p>'; $username = ""; } } else echo "Please enter all of the fields"; } ?> <form id="report_sighting" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <h2>Report a sighting</h2> <table> <tr> <td> <label>First name:</label> </td> <td> <input type="text" id="firstname" name="firstName" value="<?php if (!empty($firstname)) echo $firstname; ?>" /> </td> </tr> <tr> <td> <label>Middle name:</label> </td> <td> <input type="text" id="middlename" name="middleName" value="<?php if (!empty($middlename)) echo $middlename; ?>" /> </td> </tr> <tr> <td> <label>Last name:</label> </td> <td> <input type="text" id="lastname" name="lastName" value="<?php if (!empty($lastname)) echo $lastname; ?>" /> </td> <tr> <td> <label>Upload Identification:</label> </td> <td> <input type="file" id="image" name="image" /> </td> <tr> <tr> <td> <label>Contact phone number: </label> </td> <td> <input type="text" id="phone" name="phone" /> </td> <tr> <tr> <td> <label>Organisation: </label> </td> <td> <input type="text" id="organisation" name="organisation" /> </td> </tr> <tr> <td> <label>Street seen: </label> </td> <td> <input type="text" id="street" name="street" /> </td> </tr> <tr> <td> <label>Town seen: </label> </td> <td> <input type="text" id="town" name="town" /> </td> </tr> <tr> <td> <label>City seen: </label> </td> <td> <input type="text" id="city" name="city" /> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="Report" name="report" /> </td> </tr> </table> </form> </body> </html> I've checked out the SQL statement and it's alright, so that leaves me with the PHP. I would very much appreciate if anyone could help me out here, thanks. im doing smting basically wrong Code: [Select] <form action="" method="post"> <?php $x=1; $images = $_GET['images']; for( $i=0; $i<$images; $i++ ) { echo '<input name="ID" type="hidden" value="1234" /> <br> <input name="ImageURL['.$i.']" type="file" value=""/><br><br>'; } ?> <input name="submit" type="submit" /> <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("international", $con); if (isset($_POST['submit'])) for( $i=0; $i<$images; $i++ ) { $query=mysql_query("INSERT INTO images (ID,ImageURL) VALUES ('$_POST[ID]','$_POST[ImageURL]')"); exit; mysql_close($con); } ?></form> I set up a Twilio number so a client could have a SMS keyword response setup... but I don't know how to get the contents of a file to be returned as the response. I am using the php functions.. I setup a system so that my client could change the responses to different keywords. Basicly it uses a webform to change the contents of a file which gets returned as a response. What I need to know is how to read in the contents of the file into this function: BTW... this works fine and will return "READ_FILE_CONTENTS_INTO_HERE" function app(){ $response = new Services_Twilio_Twiml(); $response->sms("READ_FILE_CONTENTS_INTO_HERE"); echo $response; } I tried this but it stopped the script dead: function app(){ $response = new Services_Twilio_Twiml(); $response->sms("<?php include 'file.txt'; ?>"); echo $response; } Any ideas? Thanks BTW... below is the entire php script: <?php /* Include twilio-php, the official Twilio PHP Helper Library, * which can be found at * http://www.twilio.com/docs/libraries */ include('Services/Twilio.php'); /* Controller: Match the keyword with the customized SMS reply. */ function index(){ $response = new Services_Twilio_Twiml(); $response->sms("Thank You For Contacting SweetLeafAZ.com - Reply with one of the following keywords: APP = Make Appt, CS = Current Strains, DP = Delivery Prices, SP = Current Specials."); echo $response; } function app(){ $response = new Services_Twilio_Twiml(); $response->sms("http://www.vcita.com...01f2c7d/home"); echo $response; } function cs(){ $response = new Services_Twilio_Twiml(); $response->sms("http://mobile.dudamo...sweetleafaz2"); echo $response; } function dp(){ $response = new Services_Twilio_Twiml(); $response->sms("As of Sept 26 2014, Our Delivery Rates are $2 per mile during the hours of 9am to 6pm. No deliveries will be made after 6pm."); echo $response; } function sp(){ $response = new Services_Twilio_Twiml(); $response->sms("We are currently offering FREE delivery within 10 miles for orders over $100."); echo $response; } /* Read the contents of the 'Body' field of the Request. */ $body = $_REQUEST['Body']; /* Remove formatting from $body until it is just lowercase characters without punctuation or spaces. */ $result = preg_replace("/[^A-Za-z0-9]/u", " ", $body); $result = trim($result); $result = strtolower($result); /* Router: Match the ‘Body’ field with index of keywords */ switch ($result) { case 'app’': app(); break; case 'cs': cs(); break; case 'dp': dp(); break; case 'sp': sp(); break; /* Optional: Add new routing logic above this line. */ default: index(); } hi, this piece of code is not working, is it ok? Code: [Select] $query1 = "SELECT * FROM members_copy WHERE RSUSER = '".$RSUSER."' AND RSPASS = '".$RSPASS."'"; $result1 = mysql_query($query1); $row1 = mysql_fetch_array($result1); $_SESSION['USERID']=$row1['USERID']; $_SESSION['rsTown']=$row1['rsTown']; $_SESSION['RSEMAIL']=$row1['RSEMAIL']; $_SESSION['RSUSER']=$row1['RSUSER']; $pSQL = "INSERT INTO favepub_copy (USERID,PUBID)"; $pSQL = $pSQL."SELECT ".$_SESSION['USERID'].", PUBID "; $pSQL = $pSQL."FROM pubs "; $pSQL = $pSQL."WHERE rsTown = '".$rsTown; //echo "hello world"; //echo $pSQL; //exit(); mysql_query($pSQL); Hi, I'm quite new to php and not the greatest of coders, so urgently require your help. I want to be able to take data from an un-normalised table and load into 2 normalised tables as below: 1) Table 1 - All Music Tracks (Un-normalised table) Album Name Artist Name Track Name Track Length etc. 2) Table 2 - Albums Table (Normalised table) ID Artist Name Album Name etc. 3) Table 3 - Tracks Table (Normalised table) ID Track Name Album ID (foreign key to Albums table) etc. Can someone please provide some sample code as a starting point? The All Music Tracks table includes both the album name and track name in each row, but I only want the album appearing once in the Albums tables, would I have to do an Distinct select first to get the album names into an array? I'm not sure how I would then have nested loop to do the insert into the Tracks table. Much Appreciated, PD Im trying to insert some values automatically into a table once the form loads, but Im getting an error. Here is the code Code: [Select] <?php $aid = $_GET['aid']; $sd = $_GET['sd']; ?> <style> #message {margin:20px; padding:20px; display:block; background:#cccccc; color:#cc0000;} </style> <div id="message">Your notification has been submitted.</div> <div style="text-align:center "> <?php $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="INSERT INTO broken_links (articleid, article) VALUES ('$aid', '$sp')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Submitted"; mysql_close($con) ?> <table border="0" cellpadding="3" cellspacing="3" style="margin:0 auto;" > <input type="submit" id="Login" value=" Thank you. Please press to close " onclick="tb_remove()"></td> </tr> </table> </div> Any help will be appreciated |