PHP - Confused By The Data I'm Receiving From Mysql
Apologies, first off: I only venture into PHP occasionally and my problem is something very very obvious...
The data I'm getting back from the script below differs radically from the data recovered by the same SQL applied directly in phpMyAdmin. $sql = mysql_query('SELECT `fid` , `title` , `extension` FROM files WHERE `mid_FK` = 2353 ORDER BY `title`') or die ("Sorry: cannot retrieve files."); $files_found = mysql_fetch_array($sql); $num_files_found = count($files_found); The native SQL returns three rows from the table, all with entries in each column. What my script produces as relevant variables is this. Code: [Select] [sql] => Resource id #6 [files_found] => Array ( [0] => 961 [fid] => 961 [1] => Abstract of Case [title] => Abstract of Case [2] => doc [extension] => doc ) [num_files_found] => 6 This is the first row of the SQL results, duplicated. Whereas what I need are the entries for all three rows. I'm baffled, not least because I copied it out of another script I wrote last time I was doing this sort of thing, which has been working fine ever since. Similar TutorialsHi all, I should first mention I'm not much of a coder, I'm using PHP to create a custom weather solution for myself. Basically am pulling XML from weather.gov and working with the data. So far, so good. I'm getting the data I want displayed correctly, but noticed when I refresh the page I sometimes receive old data. (From the past hour, two hours, etc.) I figured this was cached info and I'm trying to figure out how to clear that out. This is how I'm accessing the XML: $url = 'http://forecast.weather.gov/MapClick.php?lat=40.65160&lon=-74.34420&FcstType=digitalDWML'; $xml = file_get_contents($url); I did some research and tried the following headers, but that doesnt seem to work: <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); ?> Also tried appending a random number onto the $url, (as per a forum question/response somewhere) but that didn't work. Anyone suggestions would be great. Thanks I'm trying to set up paypal payment processing on my website. I have godaddy shared hosting (<--mistake) and I'm trying my hardest to not switch hosts. The payments process fine, it is the listener that I'm having problems with. Paypal POSTs data to a script for which you set the url to a "listener" script in your settings. When a payment is made.... they POST the data to the listener script... you encode the data...append it all together plus another variable and send it back to be verified that it matches... Well I'm not too worried about the script working and all that... the problem is I'm not even RECEIVING the post. I have a simple foreach loop gather and append the data into a string. I have it set up right now to insert into MYSQL just so I can SEE if it's working....You can check your IPN history and I can see that payments are made but paypal is sending it over and over it's in a "retrying" state with a 408 error. My server is not sending a 200ok response. After 4 days of bashing my head against the wall I figured out that there's a problem with godaddy shared hosting.. If I use a virtual private server with the SAME script from godaddy it works just fine. But on the shared hosting it blocks it for some reason...After calling paypal and godaddy countless times with them pointing their finger at each other... one godaddy support rep tells me that I should set my script up with a proxy and he gave me info which I will show you in the script... This is what I need help with right. How can I receive POST data through a proxy in my script.... I want to add that this doesn't make sense to me because in my script I also have the word "yes" insert into MYSQL even if the script is hit at all... All this time my script is NEVER even touched by paypal... So.. if I add this proxy stuff... how will let my script even be accessed? I'm not sure how servers work together too well to process things. It just didn't seem like the proxy thing would even help when my script can't even be accessed it seems. Any help is appreciated. Here's the simple code I'm working with: $con = mysql_connect("","","") or die(mysql_error()); $db = mysql_select_db("swellshirt",$con); $ip = "64.202.165.130"; // proxy IP <-- IP... $port = 3128; // proxy port $url_proxy = 'http://proxy.shr.secureserver.net'; // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } mysql_query("INSERT INTO orders (description, street) VALUES ('$req', 'yes') ") or die(mysql_error()); This has probably been asked a bunch of times , but : I only recently started to self learn PHP , and this small project i am making is quite a challange for me. The scripts below are not realy writen by me , but i wished to tie them together to get a fully working code. What is suppose to happen is : In the form i wish to put a special button that puts extra input fields in the form. After the form is submited ,with whatever amount of feilds in it, the data goes to a processing.php file that sorts all the info gathered and finaly sends all this data formated in to the last file that will be inluded in the index.php. i already have the code for increcing the amount of inputs but the problem is , all inputs have the same names. Coz of that i get a mess. What i need is each input to have a unique name or id , that way the processing file would receive different names(id's) with different values(what ever is writen in the inputs by users). for example: I have 2 enitial fields displayed on form.html , i click the button "add new" 5 times and add 5 more input fields. All this data must be sent to a process.php and on the output write all of this information formated in the last file in a row that will be displayed in the index by useing <?include("blablabla.php");?> The input increment is done by a java script. the problem is sending data with unique id(name) and receiving it. The form file : <?include("header.php");?> <?$i = 1; ?> <script type="text/javascript"> function validate(frm) { var ele = frm.elements['feedurl[]']; if (! ele.length) { alert(ele.value); } for(var i=0; i<ele.length; i++) { alert(ele[i].value); } return true; } function add_feed() { var div1 = document.createElement('div'); // Get template data div1.innerHTML = document.getElementById('newlinktpl').innerHTML; // append to our form, so that template data //become part of form document.getElementById('newlink').appendChild(div1); } var ct = 1; function new_link() { ct++; var div1 = document.createElement('div'); div1.id = ct; // link to delete extended form elements var delLink = '<div style="text-align:right;margin-right:65px"><a href="javascript:delIt('+ ct +')">Del</a></div>'; div1.innerHTML = document.getElementById('newlinktpl').innerHTML + delLink; document.getElementById('newlink').appendChild(div1); } // function to delete the newly added set of elements function delIt(eleId) { d = document; var ele = d.getElementById(eleId); var parentEle = d.getElementById('newlink'); parentEle.removeChild(ele); } </script> <TABLE> <style> #newlink {width:600px} </style> <form action='sendorder.php' method='post'> <div id="newlink"> <div> <table align="center" border=0> <TR><TD><B>Product:</B> </TD><TD><input type=text name=prodname1 value="<?=$_GET['prodname1'];?>"> </TD> <TD><B>Price:</B> </TD><TD><input type=text name=price1 value="<?=$_GET['price1'].$curency;?>"><b>%</b></TD></TR> </table> </div> </div> <p> <br> <input type="submit" name="submit1"> <input type="reset" name="reset1"> </p> <p id="addnew"></p> <FORM> <INPUT type="button" value="Add New" name="button2" onClick="javascript:new_link()"> </FORM> </form> <!-- Template --> <div id="newlinktpl" style="display:none"> <div> <table border=0> <TR><TD><B>Product:</B> </TD><TD><input type=text name=<?$_POST[++$i];?> value="<?$_GET[$i];?>"> </TD> <TD><B>Price:</B> </TD><TD><input type=text name=<?$_POST [++$i];?> value="<?$_GET[$i].$curency;?>"> </TD></TR> </form> </TABLE> <?include("footer.php");?> in the code above i tryed to make the programm POST the numbers in the name increcing it by 1. But when i click submit i get offset error. The processing file : <? $timestamp = strftime("%d-%m-%Y %H:%M:%S %Y"); // for later use (ignore it) $i =1; #################################################################################### if(($_POST['prodname']!="")&&($_POST['price']!="")){ ############################################################ $writetocsv = $_POST['prodname1'] . "," . $_POST['price1']"%" <BR> . $_POST[$i] . $_POST[$i]; $fp = fopen("data/data.csv", "a"); fwrite ($fp,$writetocsv); fclose ($fp); echo "<script>alert('Data sent.')</script>"; } else{ echo "<script>alert('Error! Please fill the form!')</script>"; } echo "<script>location.replace('index.php')</script>"; ?> Perhaps someone knows a easyer way , since i am not sure how to make stuff due to the lack of knowlage in php. I also tryed arrays but , as said before , too tough when you are a noob Please help. I am being sent an XML feed which needs to be downloaded in a 'compressed way'.
The example I have been given is this:
$url = 'http://myurl.com'; $headers[] = "Accept-Encoding: gzip,deflate"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $data = curl_exec($ch); but the output I am getting is jargon like this with loads of black diamond question marks:� +T��sƒ���-}#v���]K���������HB�$&G�����Y�����'߷s�,�.4֫'?'���9;*9^��>�j~�ǫ}z|hq�J��Գ".o2)~b���U~I| How to a convert it back into XML? Many thanks Edited by samjsharples, 30 September 2014 - 03:49 PM. Hi I am trying to display data from the table "event" in my database, I use the code below but it will not work and I cannot figure out why. CAn anyone help? CODE: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="event"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $result = my_sql_query("SELECT * FROM event WHERE eventid = '1'"); while($row = mysql_fetch_array($result)) { $eventname= $row["eventname"]; $eventdate= $row["eventdate"]; echo "<b><u>Event Name:</b></u> $eventname" echo "<b><u>Event Date:</b></u> $eventdate<br>"; } ?> DISPLAY: Event Name: $eventname echo "Event Date: $eventdate "; } ?> I'm updating some PHP/MySQL code and struggling to get it to work correctly. At the moment I have the code as follows: if (strlen($number) < "9" AND $number1 <> "101"){ } else if (strlen($number) > "14") { } else { ...........the rest of the code goes here to action after filtering out the above.
I want the first if command to match if the length is less than 9 characters long, and the $number1 is either 101 or (I want to add in 102). I've tried amending the first IF statement to read as follows, but that fails: if (strlen($number) < "9" AND ($number1 <> "101") OR ($number1 <> "102")){ } I'm expecting it to be something very straightforward, but I've looked at it for so long now I just cannot see it. Thanks in advance for any help.
Hi, I have been trying to get the below code to work but without luck for the past couple of days. Can anyone help point out where i am going wrong. I have a webpage that has several buttons which will eventually let users search for data stored in different tables of a postgresql database ( i have simplified the code here to just two buttons). When the user clicks the Search for hostname button a form is displayed letting them type in their search criteria. Upon clicking the submit button i am able to access the users search strings with no problem but i cannot get the original search form to display above the search results additonaly including the users original search strings. Any help on this would be much appreciated as i am pulling my hair out, as you can probably guess i am very new to PHP/HTML My code is <? session_start(); ?> <form method="POST" action="<? echo $_SERVER['PHP_SELF'];?>"> <center> <button type="submit" id="green_button" name="searchhostname">Search for Hostname</button> <button type="submit" id="green_button" name="searchipaddress">Search for IP address</button> </center> </form> </body> <? // If user clicks the search hostname button display the additonal search form if ($_POST['searchhostname']) { echo "Search for Hostnames and IP Addresses:<br><br>"; echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'>"; echo "Hostname: <input type='text' name='hostname' size='16' value='".$_POST['hostname']."'/>"; echo "<br>"; echo "Operating System: <input type='text' name='ostype' size='16' value='".$_POST['ostype']."'/>"; echo "<br>"; echo "<input type='submit' id='green_button' value='Search' name='runsearch'><br><br>"; echo"</form>"; } // If user has entered criteria to search on run the search but alos display the original search form above // and any data the user has entered before displaying results if ($_POST['runsearch']) { //In reality this is where the users search data will be compared to a postresql database.... echo "You want to search for hostname: ".$_POST['hostname']."<br>"; echo "You want to search for operating system: ".$_POST['ostype']."<br>"; } ?> Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. This could be PHP or MySql so putting it in PHP forum for now... I have code below (last code listed) which processes a dynamically created Form which could have anywhere from 0 to 6 fields. So I clean all fields whether they were posted or not and then I update the mySQL table. The problem with this code below is that if, say, $cextra was not posted (i.e. it wasnt on the dynamically created form), then this code would enter a blank into the table for $cextra (i.e. if there was already a value in the table for $cextra, it gets overwritten, which is bad). What is the best way to handle this? I'm thinking i have to break my SQL query into a bunch of if/else statements like this... Code: [Select] $sql = "UPDATE cluesanswers SET "; if (isset($_POST['ctext'])){ echo "ctext='$ctext',"; } else { //do nothing } and so on 5 more times.... That seems horribly hackish/inefficient. Is there a better way? Code: [Select] if (isset($_POST['hidden']) && $_POST['hidden'] == "edit") { $cimage=trim(mysql_prep($_POST['cimage'])); $ctext=trim(mysql_prep($_POST['ctext'])); $cextra=trim(mysql_prep($_POST['cextra'])); $atext=trim(mysql_prep($_POST['atext'])); $aextra=trim(mysql_prep($_POST['aextra'])); $aimage=trim(mysql_prep($_POST['aimage'])); //update the answer edits $sql = "UPDATE cluesanswers SET ctext='$ctext', cextra='$cextra', cimage='$cimage', atext='$atext', aextra='$aextra', aimage='$aimage'"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { } Hi I am trying to select and order data/numbers from a colum in a mysql data base however i run the code and it returns no value just a blank page no errors or any thing so i think the code is working right but then it returns no result? Please help thanks Here is the code: <?php $host= "XXXXXX"; $mysql_user = "XXXXXX"; $mysql_password = "XXXXXX"; $mysql_database = "XXXXXXX"; $connection = mysql_connect("$host","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server."); mysql_select_db($mysql_database) or die ("Unable to select requested database."); $row = mysql_fetch_assoc( mysql_query( "SELECT XP FROM Game ORDER BY number DESC LIMIT 1" ) ); $number = mysql_result(mysql_query("SELECT XP FROM Game ORDER BY number DESC LIMIT 1"), 0); echo "The the highest XP is $number"; ?> hi guys, im new to this forum I'm new also to php, I need help from you guys: I want to display personal information from a certain person (the data is on the mysql database) using his name as a link: example: (index.php) names 1. Bill Gates 2. Mr. nice Guy i want to click Bill Gates (output.php) Name: Bill Gates Country:xxxx Age: xx etc. How can i make this or how to learn this? I have a form on our website that a user can fill out for custom product. I want the form data to be 1) stored into a mysql database AND after storing said data, 2) email the same data to our sales department. 1) The form data DOES get stored into mysql database (except for the first two fields, for some weird reason) 2) I added a "mail" section to the php file that stores the data into the database, but it is not working correctly. I have stripped the email portion down to sending just one of the fields in the "message" to make it easier for troubleshooting I have included here, both the form section of the html file, and the formdata.php file that processes the data for your analysis. I am relatively new to php so there are going to be some issues with security, but I can work on those after I get the store & email process to work correctly. Please review my code and see if anyone can be of assistance. I looked through the forums and couldn't find another issue that was the same as mine. If I just overlooked, please tell me the thread post #. Thanks THE FORM WHICH COLLECTS THE DATA ******************************* <form method=POST action=formdata.php> <table width="640" border=0 align="center"> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=FName size=25></td> <td><div align="right"><b>Telephone</b></div></td> <td><input type=text name=Tel size=25></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=LName size=25></td> <td><div align="right"><b>Fax</b></div></td> <td><input type=text name=Fax size=25></td> </tr> <tr> <td align=right><b>Title</b></td> <td><input type=text name=Title size=25></td> <td><div align="right"><b>Email</b></div></td> <td><input type=text name=Email size=50></td> </tr> <tr> <td align=right><b>Company</b></td> <td><input type=text name=Comp size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Address</b></td> <td><input type=text name=Addr size=25></td> <td><div align="right"><b>Estimated Annual Volume</b></div></td> <td><input type=text name=EAV size=25></td> </tr> <tr> <td align=right><b>City</b></td> <td><input type=text name=City size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>State/Province</b></td> <td><input type=text name=SProv size=25></td> <td><div align="right"><b>Application</b></div></td> <td><input type=text name=Appl size=25></td> </tr> <tr> <td align=right><b>Country</b></td> <td><input type=text name=Ctry size=25></td> <td><div align="right"><b>Type of System</b></div></td> <td><input type=text name=Syst size=25></td> </tr> <tr> <td align=right><b>Zip/Postal Code</b></td> <td><input type=text name=ZPC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td><div align="right"><strong><font color="#FFFF00" face="Arial, Helvetica, sans-serif">COIL DESIGN</font></strong></div></td> <td><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PARAMETERS</strong></font></td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Primary Resistance (ohms)</b></td> <td><input type=text name=Pres size=25></td> <td><div align="right"><b>Primary Inductance (mH)</b></div></td> <td><input type=text name=Pind size=25></td> </tr> <tr> <td align=right><b>Secondary Resistance (ohms)</b></td> <td><input type=text name=Sres size=25></td> <td><div align="right"><b>Secondary Inductance (H)</b></div></td> <td><input type=text name=Sind size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Peak Operating Current (Amps)</b></td> <td><input type=text name=POC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Output Energy (mJ)</b></td> <td><input type=text name=Egy size=25></td> <td><div align="right"><b>Output Voltage (kV)</b></div></td> <td><input type=text name=Volt size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b># HV Towers per Coil</b></td> <td><input type=text name=TPC size=25></td> <td><div align="right"><b># of Coils per Package</b></div></td> <td><input type=text name=CPP size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <th colspan=4><b>Please enter any additional information he </b></th> </tr> <tr> <th colspan=4><textarea name=Mess cols=50 rows=10 id="Message"></textarea></th> </tr> </table> </dl> <div align="center"> <p> <input type=hidden name=BodyTag value="<body bgcolor="#484589" text="#FFFFFF" link="#FFFF00" alink="#FFFFFF" vlink="#FF7F00">"> <input type=hidden name=FA value=SendMail> </p> <p><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PLEASE MAKE SURE ALL INFORMATION<br> IS CORRECT BEFORE SUBMITTING</strong></font></p> <p> <input type=submit value="Submit Form"> </p> </div> </form> THE FILE THAT PROCESSES THE FORM DATA (formdata.php) *********************************************** <?php $con = mysql_connect("localhost","XXX","XXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customform", $con); $sql="INSERT INTO formdata (Fname, Lname, Title, Comp, Addr, City, SProv, Ctry, ZPC, Tel, Fax, Email, EAV, Appl, Syst, Pres, Pind, Sres, Sind, POC, Egy, Volt, TPC, CPP, Mess) VALUES ('$_POST[Fname]','$_POST[Lname]','$_POST[Title]','$_POST[Comp]','$_POST[Addr]','$_POST[City]','$_POST[SProv]','$_POST[Ctry]','$_POST[ZPC]','$_POST[Tel]','$_POST[Fax]','$_POST[Email]','$_POST[EAV]','$_POST[Appl]','$_POST[Syst]','$_POST[Pres]','$_POST[Pind]','$_POST[Sres]','$_POST[Sind]','$_POST[POC]','$_POST[Egy]','$_POST[Volt]','$_POST[TPC]','$_POST[CPP]','$_POST[Mess]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Your Information Was Successfully Posted"; mysql_close($con); $to = "recipient email address here"; $subject = "Custom Form"; $email = $_POST['Email'] ; $message = $_POST['Comp'] ; $headers = "From: $Email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> My specific situation is SEOMoz, but this is a general question. I have a pretty extensive series of tools that rely on the SEOMoz api. They recently implemented 1 request per 10 seconds throttle limit. Is there a way I can run one request, stop for 10 seconds, and run the next, and so on? Anyway to get around something like this, without breaking their TOS? I want some code to receive email, reformat and then forward to another email address
I'm not sure where to start with this
Does the application need to be constantly running - monitoring incoming emails?
What is involved?
I did a search and saw many discussions saying that Google App Engine was available for usage
I've no experience of this
Just looking for suggestions
Thanks
OM
i have a shopping cart set up with mysql with a $_COOKIE['cart_id'] used to call all rows with cart_id... i have a while loop print out all the items in the cart $sql2 = mysql_query("SELECT * FROM cart WHERE cart_id = '$cart_id'") or die(mysql_error()); while($row = mysql_fetch_array($sql2)){ then i have it echo out the name...desc... quantity of each item... but the quantity is set up to be able to change and i have a form set up and i'd like to have each item be able to be changed at once if they wanted....but being multiple rows... there could be multiple $_POST['quantity']... echo "<td><input type='text' name='quantity' value='".$quantity."'/></td>"; there is a unique id for each row in the table that i'd like to set up with an array to post... i'd like to set up an array $array[$uniq_id] => $quantity; and somehow POST this array name='$array[]' and then on the action end... be able to call it by having foreach($quantity as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } i'm not sure if i'm approaching this the right way... the array part is leaving me stuck...any help is appreciated..thank you! Hi, I have products page which products page and I am echoing the ID of each product into a link with the description of the product as the anchor text. Code: [Select] <a href="product.php?ID=<?php echo $row['ID']; ?>" class='productlink' ><?php echo $row['description']; ?></a> However I am struggling to Get the information from the receiving 'product.php' page. The code I have on the product.php page is as follows: Code: [Select] <?php $ID = 0; if (isset($_GET['ID'])) { $ID = $_GET['ID']; } ?> <?php echo $_GET['price']; // outputs: 1 ?> However nothing is being echoed out. I just a blank screen. Am I missing like capital letters. My column is title 'ID'. Do I need to query the database in someway on the receiving page or do I just use a different GET code? Hi everyone, First off I have to mention I'm a newbie so my php knowledge is limited -sorry, but this is why I turn to you guys. I have a basic emailform.php= a field into which the user inputs his email address and I should be getting some sort of a message announcing me he signed up. But the last part isn't happening - I've tried emails from yahoo, gmail and from the sitedomain itself. Also I've tried these emails in the php form itself (email to section). I also gotta mention I may have deleted a php.ini file from the root server (I don't really remember exactly). Hosting is with godaddy (I know it sux but please bear with me.) Also my website is not in English so I need special characters (so it's UTF8). I'd be so grateful if you could help me out here - in return I'm offering a drink if you're ever in the vicinity of Milan (Italy) and my permanent respect to the world of programmers EMAILFORM.PHP Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "ajutor@t-ajutam.net"; $email_subject = "New e-mail subscriber"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form your submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if (!isset($_POST['email'])) { died('We are sorry, but there appears to be a problem with the email your submitted.'); } $email_from = $_POST['email']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Email: ".clean_string($email_from)."\n"; // create email headers $headers = 'From: ajutor@t-ajutam.net'; 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <? } ?> and HTML index Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>T-ajutăm nu este încă gata. </title> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> <script type="text/javascript" src="js/jquery.countdown.js"></script> <script type="text/javascript" src="js/jcarousellite1.0.1_min.js"></script> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'83f9b168-ba78-4f14-af11-992f92dcf19b'});</script> <!-- jquery countdown--> <script type="text/javascript"> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 2, 0, 0); $('#defaultCountdown').countdown({until: austDay, layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'}); $('#year').text(austDay.getFullYear()); }); </script> <!-- jquery slider --> <script type="text/javascript"> $(function() { $("#slidertext").jCarouselLite({ btnNext: ".next", btnPrev: ".prev" }); }); </script> <!--script for IE6-image transparency recover--> <!--[if IE 6]> <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script> <script> /* EXAMPLE */ DD_belatedPNG.fix('#logo img,#main,.counter,.twitter,.facebook,#submit_button,.prev img,.next img,#email_input'); </script> <![endif]--> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21856062-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <div class="container"> <div id="header"> <div id="logo"> <a href="index.html"><img src="images/logo.png" alt="logo"/></a> </div><!--end logo--> <div id="contact_details"> <p><a href="mailto:ajutor@t-ajutam.net">Contact</a></p> </div><!--end contact details--> </div><!--end header--> <div style="clear:both"></div> <div id="main"> <div id="content"> <div class="text"> <h2>T-ajutăm nu este încă gata</h2> <br> <p><font color=#e5e5e5>Dacă ne laşi adresa ta de email mai jos te anunţăm când suntem gata.</font></p><br> </div><!--end text--> <div class="details"> <!--slider prev button--> <a class="prev" href="#"><img src="images/prev.png" alt="" /> </a> <div id="sliderwrap"> <div id="slidertext"><!-- The slider --> <ul style="margin: 0pt; padding: 0pt; position: relative; list-style-type: none; z-index: 1; width: 6600px; left: -3000px;"> <li> <h3>Introdu adresa ta de email</h3> <!-- <form action="emailhandler.php" method="post" id="email"> <div id="submitwrapper"> <div ><input type="text" name="email" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email_input" /> </div> <div ><input type="submit" name="Submit" value="Submit" border="none" id="submit_button"/> </div> </div> </form> --> <form method="post" id="subscribeform" action="emailform.php"> <p> <div id="email_input"><input name="email" type="text" size="30" value="Enter Your E-mail" onfocus="if(this.value=='Enter Your E-mail'){this.value=''};" onblur="if(this.value==''){this.value='Enter Your E-mail'};" id="email" /> <input type="submit" id="submit_button" value="Submit" size="80" /> </div> <br /> </p> </form> </li><!-- Slider item --> <li> <h3>T-ajutăm este un nou concept de donaţii online</h3> <p>Ai nevoie de ajutor? Vrei să ajuţi dar nu ştii cum ?<p> <br> <p>Ai ajuns la locul potrivit.</p> </li><!-- Slider item --> <li> <h3>Fii la curent: urmăreşte-ne pe facebook sau twitter</h3> <div class="social"> <a class="twitter" href="http://twitter.com/t_ajutam"></a> <a class="facebook" href="http://www.facebook.com/pages/T-ajutam/178280318883554"></a> </div> </li><!-- Slider item --> <li> <h3>Ţi se pare interesant? Trimite linkul şi prietenilor tăi </h3> <span class="st_twitter_vcount" displayText="Tweet"></span><span class="st_facebook_vcount" displayText="Share"></span><span class="st_email_vcount" displayText="Email"></span><span class="st_sharethis_vcount" displayText="Share"></span> </li><!-- Slider item --> </ul> </div><!-- End of slidertext --> </div><!-- End of sliderwrap --> <!--slider next button--> <a class="next" href="#"><img src="images/next.png" alt=""/></a> </div><!--end details--> </div><!--end content--> </div><!--end main--> <div id="footer"></div> <!-- Footer start --> <p>Powered by <a href="http://ourtuts.com">ourtuts.com</a></p> <!-- Footer end --> </div><!--end class container--> </div> </body> </html> I am trying to retrieve certain keys of a post array. I am sending a payment form with a dynamic number of product id's. I will never know how many product id's will be sent for each order. When the post array returns the values to my script it returns them as: Code: [Select] $_POST['product_id_1'], $_POST['product_id_2'], etc. How would I be able to extract all post array keys that start with "product_id_? Here is what I was thinking earlier, but it doesn't work. Code: [Select] $i = 1; foreach ($_POST['product_id_' . $i] as $product) { $productId = $product['product_id_' . $i]; $queryInsert = mysql_query("INSERT INTO video_purchase (video_purchase_purchase_id, video_purchase_video_id) VALUES ($purchaseId, $productId)", $connect) or die(mysql_error()); $i++; } |