PHP - Page Not Working With This Code In?
Hi
I have this code in a huge PHP file but when I have this code in the page wont load but if I take it out it does anyone see whats wrong with this code. if($sponsored == "s") { $message1 = " <html> <head> <title>Event Booking Confirmation</title> </head> <body> <p>Dear ".$title." ".$firstname." ".$lastname."</p> <p>You have succesfully booked a ticket for <b>".$enameQ."</b></p> <p>Here is your booking confirmation number: <b>BID".$booking_id."</b></p> <p>Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - £".$price."</p> <p>We have received your booking details and they have been passed to the event holder</p> <p>*Subject to payment being made</p> <p>The event organiser will be in contact shortly with further event details.</p> <p>To start your fundraising efforts you can now create a fundraising page by clicking <a href='http://www.test.co.uk/register/test'><u>here</u></a><p> <p>Thank You for your booking.</p> <br/> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.com/images/email-logo.jpg' alt='logo'> </body> </html> "; $headers1 = "From: Test <noreply@test.co.uk>\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: multipart/mixed; "; $headers1 .= "boundary=".$num."\r\n"; $headers1 .= "--$num\r\n"; $headers1 .= "Content-Type: text/html; charset=iso-8859-1\r\n"; mail($email, $subject1, $message1, $headers1); } elseif($sponsored == "ns") { $message1 = " <html> <head> <title>Event Booking Confirmation</title> </head> <body> <p>Dear ".$title." ".$firstname." ".$lastname."</p> <p>You have succesfully booked a ticket for <b>".$enameQ."</b></p> <p>Here is your booking confirmation number: <b>BID".$booking_id."</b></p> <p>Tickets purchased</br> ".$team." ".$t2." ".$t3." ".$t4." Total Paid - ".$price."</p> <p>We have received your booking details and they have been passed to the event holder</p> <p>*Subject to payment being made</p> <p>The event organiser will be in contact shortly with further event details.</p> <p>Thank You for your booking.</p> <br/> <p>Kind Regards</p> <p>Test Team</p> <br/> <img src='http://www.test.com/images/email-logo.jpg' alt='logo'> </body> </html> "; $headers1 = "From: Test <noreply@test.com>\n"; $headers1 .= "MIME-Version: 1.0\r\n"; $headers1 .= "Content-Type: multipart/mixed; "; $headers1 .= "boundary=".$num."\r\n"; $headers1 .= "--$num\r\n"; $headers1 .= "Content-Type: text/html; charset=iso-8859-1\r\n"; mail($email, $subject1, $message1, $headers1); } Similar TutorialsI have a snippet of code like this below. If I have it directly on my page, it works fine. But if I move this snippet of code into an include file and use "require_once('thefile.php');", the code no longer works properly. How is that possible? FYI, this snippet is in the middle of a for loop on the regular page. Maybe you can't use includes when in a loop? I don't know. Makes no sense that it works when on the page, but not when included using require once. Any thoughts how this could be possible? I imagine there is some rule with include files that I'm missing??? This is the code and I don't think it matters exactly what its doing so I won't bother you with that. This is how it looks on the page itself... Code: [Select] if ($type=="one") { $_SESSION['cluenum']=1; //so clue #1 begins as the selected clue echo "<script type='text/javascript'>document.getElementById('clue1').style.border = '1px solid red';</script>"; //sets the styling on clue #1 $allcode = "onclick='setnumber($i);'"; } else { // type must be equal to all, so don't do anything special $allcode=""; } This is how it looks in the include file... Code: [Select] <?php if ($type=="one") { $_SESSION['cluenum']=1; //so clue #1 begins as the selected clue echo "<script type='text/javascript'>document.getElementById('clue1').style.border = '1px solid red';</script>"; //sets the styling on clue #1 $allcode = "onclick='setnumber($i);'"; } else { // type must be equal to all, so don't do anything special $allcode=""; } ?> http://paste.ee/p/OhiWv
The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working.
<script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script> i dont understand what is wrong plz help me.
here is code
$name = "img/".rand(1,9999999).".png"; $myFile = $name; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $html; fwrite($fh, $stringData); fclose($fh); $file=$name; $fst=file_get_contents($file); $im=imagecreatefromstring($fst); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_NEGATE); //Convert to Grey Scale for($i=0;$i<123;$i++){ for($j=0;$j<50;$j++){ $px=imagecolorat($im,$i,$j); if($px<0x303030){ imagesetpixel($im,$i,$j,0); }else{ imagesetpixel($im,$i,$j,0xffffff); } } } $database = unserialize(@file_get_contents("db.txt")); if($database === false) $database = array(); // modify the database if needed if($_SERVER['REQUEST_METHOD'] == 'POST'){ if($_POST['submit'] == 'Add') $database[$_POST['ident']] = substr($_POST['letter'], 0, 1); if($_POST['submit'] == 'Del') unset($database[$_POST['ident']]); if($fh = @fopen('db111.txt', 'w+')){ fwrite($fh, serialize($database)); fclose($fh); } }else{ $newimage = true; } $width = 130; $height = 40; $captcha_gridstart =1; $captcha_gridspace =2; $letters = findletters($im, $width, $height, $captcha_gridstart, $captcha_gridspace); $count = count($letters); $cellw = ($count > 0) ? intval(100 / $count) : 0; //dispeckle the image and GET co-ordinates of the characters of captcha image and return them. function findletters($image, $width, $height, $gridstart, $gridspace){ $offsets = array(); $o = 0; $atstartx = true; for($x = 0; $x < $width; $x++){ $blankx = true; for($y = 0; $y < $height; $y++){ if(imagecolorat($image, $x, $y) == 0){ $blankx = false; break; } } if(!$blankx && $atstartx){ $offsets[$o]['startx'] = $x; $atstartx = !$atstartx; }else if($blankx && !$atstartx){ $offsets[$o]['endx'] = $x; $atstartx = !$atstartx; $o++; } } $count = $o; for($o = 0; $o < $count; $o++){ for($y = 0; $y < $height; $y++){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['starty'] = $y; break; } } for($y = $height-1; $y > $offsets[$o]['starty']; $y--){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['endy'] = $y; break; } } } for($o = 0; $o < $count; $o++){ $offsets[$o]['ident'] = ""; for($x = $offsets[$o]['startx'] + $gridstart; $x < $offsets[$o]['endx']; $x += $gridspace){ for($y = $offsets[$o]['starty'] + $gridstart; $y < $offsets[$o]['endy']; $y += $gridspace){ $offsets[$o]['ident'] .= ((imagecolorat($image, $x, $y) == 0) ? "0" : "1"); #echo $offsets[$o]['ident'].'<br>'; } } } return $offsets; } $a=""; foreach($letters as $letter){ $asciiletter = $database[$letter['ident']]; if(!empty($asciiletter)) { $a.=$asciiletter; } } Hi, I have a registration page (that one works fine) where users register with minimal personal info. They also get to rate 8 categories (see bellow) 1-5. Once they hit submit it all goes into database just fine. I have also created a page for myself where I can recall all data for any registration. All data gets pulled from database correctly. When I change variables and hit submit it does not update the record in the database. I get no errors from the script, but I have narrowed the problem to the recall of categories and the ratings. If I remove them from the update script other info gets stored correctly. Here is how I recall the 8 categories and their user submitted ratings (as well as other info): Code: [Select] $category = array('AS','BE','BI','CH','CS','EG','EV','PH'); foreach ($category as $cat) { if ($cat == 'AS') $cat_name = 'Animal Sciences'; if ($cat == 'BE') $cat_name = 'Behavioral & Social Sciences'; if ($cat == 'BI') $cat_name = 'Biology'; if ($cat == 'CH') $cat_name = 'Chemistry'; if ($cat == 'CS') $cat_name = 'Computer Science'; if ($cat == 'EG') $cat_name = 'Engineering'; if ($cat == 'EV') $cat_name = 'Environmental Sciences'; if ($cat == 'PH') $cat_name = 'Physical Sciences'; echo" <tr> <td>$cat_name</td>"; $numbers = array('0','1','2','3','4','5'); foreach ($numbers as $no) { echo "<td><input type='radio' name='$cat' value='$no'"; if ($row[$cat] == $no) echo " checked/>"; else echo "/>"; echo"$no</td>"; }} And here is how I update the record (as well as other info not listed): Code: [Select] mysql_query("UPDATE registrations SET AS = '$_POST[AS]', BE = '$_POST[BE]', BI = '$_POST[BI]', CH = '$_POST[CH]', CS = '$_POST[CS]', EG = '$_POST[EG]', EV = '$_POST[EV]', PH = '$_POST[PH]' WHERE ID = '$_POST[ID]' "); Something in my recall code is creating issued for me, but I have no idea what. Thanks Code goes no place but changes some figures on the tool bar. Code: [Select] <?php ini_set('display_errors', 1); error_reporting(E_ALL); function OnSubmitForm() { $choose = ""; $variable1 = ""; $variable2 = ""; $choose = $_GET["pages"]; $variable1 = $_GET["page1"]; $variable2 = $_GET["page2"]; if ($choose == $variable1) { header("Location: http://url.com/page1"); } if ($choose == $variable2) { header("Location: http://url.com/page2"); } } ?> <form name="pages" onsubmit="return OnSubmitForm()"> <input type="text" name="call" size="25"> e<select name="pages"> <option name="page1" value="non1">page1</option> <option name="page2" value="non2">page2</option> </select> <input type="submit" name="submit" value="submit"> </p> </form> I haven't coded in about a year and am a little rusty. Here is the code. I have turned error reporting on but for some reason it is not working on my server. Code: [Select] <?php // Load The dealers in for the franchisee include("include/db_connect.php"); SESSION_START(); $franchise_id = $_SESSION['franchise_id']; // Query the database and get dealers $SQL = "SELECT * FROM dealers WHERE franchise_id = '$franchise_id' ORDER BY name ASC"; $result = mysql_fetch_array($SQL) or die(mysql_error()); while($run = mysql_fetch_array($result)) { ?><option value="<? echo $run['id']; ?>"><? echo $run["name"]; ?></option> <? } ?> <? include_once ("../includes/config.php"); include_once "../includes/dbconnect.php"; header("Content-type: image/jpeg"); $id = $_REQUEST['id']; $sql="SELECT product_image FROM tbl_product WHERE product_id='$id' "; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $image= $row['product_image']; $image=imagecreatefromstring($image); $out=ImagejpeG($image); print ($out); }?> <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect:' . mysql_error()); } mysql_select_db("Products", $con); $status = $_POST["c1"]; $result=mysql_query("SELECT * FROM btp_reviews ORDER BY status =".$status.""); mysql_db_query("Products", $result) or die("Failed Query of " . $result); mysql_close($con); ?> 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> <title>Dairy Farm Record Management</title> <link rel="stylesheet" type="text/css" href="C:\Documents and Settings\satheesh\Desktop\dairy_records\styles\styles.css" /> </head> <body bgcolor="#FFEBCC"> <?php if ( isset($_POST["submit"])) { // process form //$db = mysql_connect("localhost", "root","TWINKLE1"); //mysql_select_db("c1_cattle_history",$db); //$sql = "INSERT INTO cattle_rec (cattle_name,first_svc,second_svc,third_svc,calving_date,calf_sex,days_in_milk,milk_yld,dry_days,305_days_yld) VALUES //('$cattle_name,$first_svc,$second_svc,$third_svc,$calving_date,$calf_sex,$days_in_milk,$milk_yld,$dry_days,$days_yld')"; //$result = mysql_query($sql); require($_SERVER["DOCUMENT_ROOT"]."/dairy_logon.php"); $connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting"); mysql_select_db("$db_name"); mysql_query("INSERT INTO cattle_det (cattle_n,first_s,second_s,third_s,calving_d,calf_s,days_m,m_yld,dry_d,d_yld) VALUES ('$_POST[cattle_name]','$_POST[first_svc]','$_POST[second_svc]','$_POST[third_svc]','$_POST[calving_date]','$_POST[calf_sex]','$_POST[days_in_milk]','$_POST[milk_yld]','$_POST[dry_days]','$_POST[days_yld]')"); echo "Cattle Information Updated Successfully !\n"; } else { // display form } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table cellpadding="0" cellspacing="0" width="99%"> <tr><td align="center"> <font face="Franklin Gothic Medium" size="6" color="#FF8000">History Sheet</font></td></tr><br/> <tr><td align="left"><font face="Franklin Gothic Medium" size="4" color="#FF8000">Cattle Name : </font> <input type="text" size="15" name="cattle_name"></input><br/> </td></tr><br/> <table border="2" cellpadding="1" cellspacing="0" id="mytable"> <tr> The code given above is supposed to retrieve values from a form and update the respective columns in the MySQL database,but everytime I key-in the value and say "Submit" in the form the form is just reset and the values are also getting updated. Please do provide your valuable inputs. Thanks a mil. Satheesh P R Hello Guys n Gals too.. I have this big problem thats driving me nuts!! I have this login page that is not working. when i put the username n password all it does is reload itself. Alot of pages depend on the login and they dont work cozz login doesnt So please help me out. Thanx. Heres the code: Code: [Select] <?php include ("./common.php"); include ("./Header.php"); include ("./Footer.php"); // Login CustomIncludes end //------------------------------- session_start(); //=============================== // Save Page and File Name available into variables //------------------------------- $sFileName = "Login.php"; $sAction = get_param("FormAction"); $sForm = get_param("FormName"); //=============================== // Login Show begin //=============================== // Perform the form's action //------------------------------- // Initialize error variables //------------------------------- $sLoginErr = ""; //------------------------------- // Select the FormAction //------------------------------- switch ($sForm) { case "Login": Login_action($sAction); break; } //=============================== //=============================== // Display page //=============================== // HTML Page layout //------------------------------- ?><html> <head> <title>Pablo Online Rent-a-Car</title> <meta name="GENERATOR" content="Philmar"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head> <body style="background-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helveticabackground-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica"> <center> <table> <tr> <td valign="top"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Pablo Online Rent-a-Car</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/mazda6_1.jpg','images/home_2.jpg','images/aboutus_2.jpg','images/contactus_2.jpg')"> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/header1.jpg" width="778" height="110"></td> </tr> </table> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="55"><img src="images/header2.jpg" width="55" height="43"></td> <td width ="17"><a href="default.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','images/home_2.jpg',1)"><img src="images/home_1.jpg" alt="home" name="home" width="63" height="43" border="0"></a></td> <td width ="114" valign="middle"><a href="about.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('aboutphilmar','','images/aboutus_2.jpg',1)"><img src="images/aboutus_1.jpg" alt="aboutphilmar" name="aboutphilmar" width="114" height="43" border="0"></a></td> <td width ="111"><a href="contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contactus','','images/contactus_2.jpg',1)"><img src="images/contactus_1.jpg" alt="contactus" name="contactus" width="108" height="43" border="0"></a></td> <td width ="455"><img src="images/header3.jpg" width="438" height="43"></td> </tr> </table> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="55"><img src="images/header4.jpg" width="55" height="48"></td> <td> </td> <td width="438"><img src="images/header5.jpg" width="438" height="48"></td> </tr> </table> <?php Menu_show() ?> </td> </tr> </table> </center> <table width="760" align="center"> <tr> <td align="center"> <hr color="#800000"><center> <table> <tr> <td valign="top"> <?php Login_show() ?> </td> </tr> </table> <hr color="#800000" width="60%"> </td> </tr> </table> <center> <table> <tr> <td valign="top"> <?php Footer_show() ?> </td> </tr> </table> </center> </body> </html> <?php // Login Show end //=============================== // Login Close Event begin // Login Close Event end //=============================== //******************************************************************************** //=============================== // Login Form Action //------------------------------- function Login_action($sAction) { global $db; global $sLoginErr; global $sFileName; global $styles; switch(strtolower($sAction)) { case "login": //------------------------------- // Login Login begin //------------------------------- $sLogin = get_param("Login"); $sPassword = get_param("Password"); $db->query("SELECT member_id,member_level FROM members WHERE member_login =".$sLogin. " AND member_password=".$sPassword.""); $is_passed = $db->next_record(); //------------------------------- // Login OnLogin Event begin // Login OnLogin Event end //------------------------------- if($is_passed) { //------------------------------- // Login and password passed //------------------------------- set_session("UserID", $db->f("member_id")); set_session("UserRights", $db->f("member_level")); $sPage = get_param("ret_page"); if (strlen($sPage)) header("Location: " . $sPage); else header("Location: Reservation.php"); } else { $sLoginErr = "Login or Password is incorrect."; } //------------------------------- // Login Login end //------------------------------- break; case "logout": //------------------------------- // Logout action //------------------------------- //------------------------------- // Login Logout begin //------------------------------- //------------------------------- // Login OnLogout Event begin // Login OnLogout Event end //------------------------------- session_unregister("UserID"); session_unregister("UserRights"); if(strlen(get_param("ret_page"))) header("Location:" . $sFileName . "?ret_page=" . urlencode(get_param("ret_page"))); else header("Location:" . $sFileName); //------------------------------- // Login Logout end //------------------------------- break; } } //=============================== //=============================== // Display Login Form //------------------------------- function Login_show() { global $sLoginErr; global $db; global $sFileName; global $styles; $querystring = get_param("querystring"); $ret_page = get_param("ret_page"); $sFormTitle = "Enter username and password"; //------------------------------- // Login Show begin //------------------------------- //------------------------------- // Login Open Event begin // Login Open Event end //------------------------------- ?> <table style="width:100%"> <form action="login.php" method="POST"> <input type="hidden" name="FormName" value="Login"> <tr><td style="background-color: #336699; text-align: Center; border-style: outset; border-width: 1" colspan="2"><font style="font-size: 10pt; color: #FFFFFF; font-weight: bold"><?=$sFormTitle?></font></td></tr> <? if ($sLoginErr) { ?> <tr><td colspan="2" style="background-color: #FFFFFF; border-width: 1"><font style="font-size: 10pt; color: #000000"><?= $sLoginErr ?></font></td></tr> <? } ?> <? if(get_session("UserID") == "") { //------------------------------- //- User is not logged in //------------------------------- ?> <tr><td style="background-color: #FFEAC5; border-style: inset; border-width: 0"><font style="font-size: 10pt; color: #000000">Login</font></td><td style="background-color: #FFFFFF; border-width: 1"><input type="text" name="Login" value="<?=tohtml(get_param("Login"))?>" maxlength="50"></td></tr> <tr><td style="background-color: #FFEAC5; border-style: inset; border-width: 0"><font style="font-size: 10pt; color: #000000">Password</font></td><td style="background-color: #FFFFFF; border-width: 1"><input type="password" name="Password" maxlength="50"></td></tr> <tr><td colspan="2"> <input type="hidden" name="FormAction" value="login"> <input type="submit" value="Login"> </td></tr> <? } else { //------------------------------- // User is logged in //------------------------------- $db->query("SELECT member_login FROM members WHERE member_id=". get_session("UserID")); $db->next_record(); ?> <tr><td style="background-color: #FFFFFF; border-width: 1"><font style="font-size: 10pt; color: #000000"> <?= $db->f("member_login") ?></font> <input type="hidden" name="FormAction" value="logout"> <input type="submit" value="Logout"> </td></tr> <? } ?> <input type="hidden" name="ret_page" value="<?= $ret_page ?>"><input type="hidden" name="querystring" value="<?= $querystring ?>"></td></tr> </form></table> <? } ?> here are the three pages i am using to alter information stored in my database editrow.php <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table> <tr> <td align="center">EDIT DATA</td> </tr> <tr> <td> <table border="1"> <?php include"include/connect.php";//database connection $order = "SELECT * FROM products"; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ print " <td>" . $row["prod_id"] . "</td>"; print " <td>" . $row["prod_name"]. "</td>"; print " <td>" . $row["prod_price"] . "</td>"; print " <td>" . $row["prod_desc"]. "</td>"; print " <td>" . $row["prod_colour"] . "</td>"; print ("<td><a href=\"editform.php?id=$row[prod_id]\">Edit</a></td></tr>"); } ?> </table> </td> </tr> </table> </body> </html> then editform.php <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table border=1> <tr> <td align=center>Form Edit Employees Data</td> </tr> <tr> <td> <table> <?php include "include/connect.php";//database connection $id = $_GET['id']; $order = "SELECT * FROM products WHERE prod_id='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> <form method="post" action="include/updatedata.php"> <input type="hidden" name="prodid" value="<? echo "$row[prod_id]"?>"> <tr> <td>Name</td> <td> <input type="text" name="prodname" size="20" value="<?php echo "$row[prod_name]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="prodprice" size="40" value="<?php echo "$row[prod_price]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="proddesc" size="40" value="<?php echo "$row[prod_desc]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="prodcolour" size="40" value="<?php echo "$row[prod_colour]"?>"> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit value" value="Edit"> </td> </tr> </form> </table> </td> </tr> </table> </body> </html> now here it all goes weird i get this error Notice: Undefined index: $id in C:\wamp\www\uniwork\include\updatedata.php on line 4 but without it it doesnt know how to get the information from the previous form. include/updatedata.php <?php //edit_data.php include "connect.php"; $id=$_GET['$id']; $order = "UPDATE products SET prod_name='prodname', prod_price='prodprice', prod_desc='proddesc', prod_colour='prodcolour' WHERE prod_id='$id'"; mysql_query($order); header("location:updatedata.php"); ?> <?php require_once("includes/connection.php");?> <html> <head> <style type="text/css"> <!-- a:link { color: #000000; text-decoration: none; } a:visited { text-decoration: none; color: #000000; } a:hover { text-decoration: underline; color: #FFFFFF; } a:active { text-decoration: none; color: #000000; } a { font-family: Courier New, Courier, monospace; } body,td,th { font-family: Courier New, Courier, monospace; font-size: 18px; } .style1 {font-size: 40px} #one { text-align:center; vertical-align:top; } #parent { position:absolute; left:60px; font-size:14px; } --> </style> </head> <body> <table width="100%" height="888" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="186" colspan="2" bgcolor="#CCCCCC"><div align="center" class="style1">DOWNLOAD TREASURE </div></td> </tr> <tr> <td id="one" width="16%" bgcolor="#99CCFF" ><?php $result =mysql_query("SELECT * FROM subjects",$connection); if(!$result){ die("connection error : ".mysql_error()); } while($row = mysql_fetch_array($result)){ echo $row["menu_name"]."<br/>"; } $parent = mysql_query("SELECT * FROM pages WHERE subject_id = {$row["id"]}" ,$connection); if(!$parent){ die("connection error : ".mysql_error()); } while($rowone = mysql_fetch_array($parent)){ echo $rowone["menu_name"]; } ?></td> <td width="84%"> </td> </tr> </table> </body> </html> is there any mistake here.it is a big help for me. <?php session_start(); if($_SESSION['username']) echo "Welcome, ".$_SESSION['username']."!<BR>"; echo "<a href=\"logout.php\">LOGOUT</a>"; else die("Your Have To Be Logged In To View This Page"); ?> anyone see anything wrong with this i'm getting a parse error on line 8 that is the else statment I have some PHP code that should give me the dates in year order but it is giving me the date order. So it shows a list of 10 items in the following order see attached png it should show the ten items i sorted by year then month then day, <?php $sql = "SELECT GAME, YR, PLATFORM, PUBLISHER, FINISHED FROM games WHERE COMPLETED='✔' ORDER BY FINISHED DESC LIMIT 10;"; $result = mysqli_query($conn, $sql) or die("Bad Query: $sql"); $num_rows = mysqli_num_rows($result);?> <?php while ($row = mysqli_fetch_assoc($result)): ?> <tr> <td><?php echo $row['GAME']; ?></td> <td><?php echo $row['PLATFORM']; ?></td> <td><?php echo date('d F Y', strtotime($row['FINISHED'])); ?></td> <tr> <?php endwhile; ?> This use to work on until this week
I am a newbie PHP Web Developer and currently reading the book 'PHP and MYSQL Web Development' by Luke Welling and Laura Thomson. Following what was written in the book, that is what I got:
<?php $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; $address = $_POST['address']; $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; $date = date('H:i, jS F Y'); ?> <html> <head> <title>Order Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php if($tireqty == 0 && $oilqty == 0 && $sparkqty == 0){ echo '<p>You did not order anything on the previous page!</p>'; exit; }else{ echo '<p>Order Processed at '.$date.'</p>'; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo 'Items ordered: '.$totalqty.'<br />'; $totalamount = 0.00; define('TIREPRICE',100); define('OILPRICE',10); define('SPARKPRICE',4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($totalamount,2).'<br />'; $taxrate = 0.10; $totalamount = $totalamount * (1 + $taxrate); echo '<p>'.'Total including tax: $'.number_format($totalamount,2).'<br /></p>'; echo '<p>Adress to ship to is '.$address.'<br />'; $outputString = $date."\t".$tireqty." tires \t".$oilqty." oil \t".$sparkqty." spark plugs \t".$totalamount."\t".$address."\n"; //opening files. @ $fp = fopen("$DOCUMENT_ROOT/booktutorials/orders.txt", 'ab'); /////////////////////////////////HERE IS WHERE IT WOULD NOT WORK AS I WANT TO //////////////////////////////////////////////////// if(!$fp){ echo "<p><strong> Your order could not be processed at this time. Please try again later.</strong></p>"; exit; } flock($fp, LOCK_EX); fwrite($fp, $outputString, strlen($outputString)); flock($fp, LOCK_UN); fclose($fp); echo "<p>Order written.</p>"; echo '<hr />'. file_get_contents("$DOCUMENT_ROOT/booktutorials/orders.txt"); } ?> </body> </html>All I get is 'Your order could not be processed at this time. Please try again later'. Even though I am pretty sure that the URL of the file is correct. Please help. Thanks in advance. Hello dear friends, okay here is the story i've 2 incoming entries Code: [Select] $name = "Manal Nor"; $comment = "Hello lovely world"; and i've stored into database table some bad words to be banned my_table (id,word) My objective Is to compare if $name and/or $comment have any of the banned words in my_table I can apply for $name only , i mean i can compare $name and know if it have any banned words or not using the following code Code: [Select] $name = "Manal Nor"; // Example .. no bad words $sql = "SELECT * FROM my_table"; $result = mysql_query($sql); $nameArray = explode(" ", $name); $countname = count($nameArray); $checkname = 0; while ($row = mysql_fetch_assoc($result)) { for ($i == 0; $i < $countname; $i++) { if (strcasecmp($nameArray[$i], $row['word'])) { $checkname = 1; } } } if ($checkname == 1) { echo "banned"; exit; }else { echo "passed"; } it works perfect but now the question how to apply it like cheese burger i mean for both $name and $comment so that i can use any help please This snippet was running perfectly on localhost, but after I uploaded the file containing this snippet on a webserver, the script does generate an error, or even displaying none (no results). #selects all data from table and displays it in textfields. If failed, it will display the error $sql = "SELECT * from tblquotes ORDER BY Rand() LIMIT 1"; $result = mysql_query($sql,$connection); if($result = mysql_query($sql ,$connection)) { $num = mysql_numrows($result); $count =0; while ($count < $num){ $q1 = mysql_result($result,$count,"quote"); $q2 = mysql_result($result,$count,"author"); $count++; } } else{ echo "ERROR: ".mysql_error(); } what seems to be the problem? Need help... I'm running on PHP 4.4.4 on Localhost and PHP 5.2.9 on the webserver. Mysql 4/5 on Localhost and Mysql 4.1.22 on the webserver I have a piece of .php that is supposed to create a type of calendar but it seems to be getting the date wrong and thinks that the date I've selected is 12/31/1969. Any ideas on how to get it to recognize the date I'm selecting in the form items? Thanks! Morgan [attachment deleted by admin] Hi, This is fairly urgent, so I appreciate any help anybody can give me ASAP. I recently upgraded from PHP 4 to 5 and now certain "include" code is not working on my site. Here's an example: Code: [Select] // if topic selected, display the relevant content. if ($topic == 'page1') { include ("$topic.php"); } elseif ($topic == 'page2') { include ("$topic.php"); } // else wrong or no link selected. else { print "Go to the <A HREF = 'main.php'>Main page</A>"; } Let's say the above code was in a PHP file called "frontpage.php". It used to be that if a person went to "mydomain.com/frontpage.php?topic=page1" then the page called for in the above code would include the content of "page1.php" in "frontpage.php". It's no longer working. Any ideas why or how to fix it? Any better way of doing this? Thanks, Steve I am running PHP Version 5.3.1. The following Code does not write to my database. It is code that I took from the PHP Pocket Reference from O'Reilly but it does not work... What's wrong with this code? Thanks in advance. Guy <?php if($vote && !$already_voted) SetCookie('already_voted',1); ?> <html> <head> <title>Name the Baby</title> </head> <h3>Name the Baby</h3> <form action="baby.php" method="POST"> <p>Suggestion: <input type="text" name="new_name"/> </p> <input type="submit" value="Submit idea and/or vote"/> <?php mysql_pconnect("localhost","root","password"); $db = "babynames"; $table = "baby_names"; if($new_name) { if(!mysql_db_query($db, "insert into $table values ('$new_name',0)")) { echo mysql_errno().': '. mysql_error()."<br />\n"; } } if($vote && $already_voted) { echo '<p><b>Hey, you voted already '; echo "Vote ignored.</b></p>\n"; } else if($vote) { if(!mysql_db_query($db, "update $table set votes=votes+1 where name='$vote'")) { echo mysql_errno().': '. mysql_error()."<br />\n"; } } $result=mysql_db_query($db,"select sum(votes) as sum from $table"); if($result) { $sum = (int) mysql_result($result,0,"sum"); mysql_free_result($result); } $result=mysql_db_query($db, "select * from $table order by votes DESC"); echo <<<EOD <table border="0"><tr><th>Vote</th> <th>Idea</th><th colspan="2">Votes</th></tr> EOD; while($row=mysql_fetch_row($result)) { echo <<<FOO <tr><td align="center"> <input type="radio" name="vote" value="$row[0]"></td> <td>$row[0]</td> <td align="right">$row[1]</td> <td> FOO; if ($sum && (int)$row[1]) { $per = (int)(100 * $row[1]/$sum); echo '<img src="bline.gif" height=12 '; echo "width=$per> $per %</td>"; } echo "</tr>\n"; } echo "</table>\n"; mysql_free_result($result); ?> <input type="submit" value="Submit idea and/or vote" /> <input type="reset" /> </form> </body></html> |