PHP - Php Code Not Working On Godaddy Hosting But Working Fine On Linux Vps
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; } } Similar TutorialsHello, I am new. I have created a very simple webpage that has content the changes when a link is clicked. The site works perfectly on my "localhost". I am running Apache 2.2 and PHP 5.3 on localhost. When I upload to my GoDaddy shared hosting, ( I beleive Apahe 1.3 and PHP 5.2) my "index.php" displays fine on load. However, when any of the links are clicked the content area where it is supposed to change disapeears. Here is a sample of the code that I am using: // These are the links in the index.php html code... <li><a href="index.php?id='home'" id="home" name="home">Home</a></li> <li><a href="index.php?id='form'" id="form" name="form">Register</a></li> <?php include("form1.php"); getPage(); ?> html.... Then on the form1.php page is the following code... function getPage() { $linkID = $_GET['id']; if ($linkID == NULL) { changeBool("'home'"); } else changeBool($linkID); } //end example The function "changeBool()" has a switch structure that is determined by the $_GET[] var. I beleive this has something to do with the php.ini settings, possibly the apache settings...any ideas would be greatly appreciated. We had to update our Linux server from php 5.4 to php 7.4. Something has changed and I have a feeling it is due to changes in fputcsv. When running the code below, instead of opening a csv file in libre calc, it fills the browser with the result. Is there a way of fixing this so I get the csv file again?
<code>date_default_timezone_set("America/New_York"); </code> Thanks for any help. This script was working fine yesterday i havn't changed anything?? not it don't register the user upon completing the script no error, just when you hit submit it refreshes and does nothing? <?php //check for submit $submit =$_POST['submit']; //gather POST variable $fullname =strip_tags($_POST['fullname']); $email =strip_tags($_POST['email']); $username =strip_tags($_POST['username']); $password =strip_tags($_POST['password']); $password2 =strip_tags($_POST['password2']); if ($submit) { //check that fields were filled in if ($fullname&&$email&&$username&&$password&&$password2) { //check to see if our two password fields match if ($password==$password2) { $password = md5($password); // register the user //open database $connect = mysql_connect("localhost", "root", ""); mysql_select_db("users"); //begine insert $queryreg = mysql_query("INSERT INTO members VALUES ('','inet_aton('127.0.0.1')','$fullname','$email','$username','$password')"); if ($queryreg) { echo "Thanks, For Registering! Click <a href=\"index.php\">HERE</a>To Login!"; } } //otherwise if passwords don't match else { echo "<font color='red'>The passwords you entered do not match</font>"; //end of checking password } } else { echo "<font color='red'>Please enter all fields!</font>"; } } //end check for submit ?> <form action='testreg.php' method="post"> <table align="center"> <tr> <td> Your Full Name: </td> <td> <input type="text" name="fullname" value="<?php echo $fullname; ?>"> </td> </tr> <tr> <td> Email Address: </td> <td> <input type="text" name="email" value="<?php echo $email; ?>"> </td> <tr> <td> Choose Username: </td> <td> <input type="text" name="username" value="<?php echo $username; ?>"> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" name="password"> </td> </tr> <tr> <td> Retype Password: </td> <td> <input type="password" name="password2"> </td> </tr> </table> <p> <center><input type="submit" name="submit" value="Register"></center> </form> 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 have been using this script for years. I realise it is a little old and probably not well written, however it has been functional. I suspect the problem is that maybe they have turned the register_globals off at the server and the script is no longer working. I don't know if that is the problem. The error I get when I attempt to upload an image is this: Error: MySQL error reported! Query: INSERT INTO photos values(NULL,'corrobex', 1, 10, , 'makinti', '', '', 'makinti.jpg', 571, 381, 42520, '0', 0, 0, 0, '1', , '0', 'no', '', '', '', '', '') Result: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'makinti', '', '', 'makinti.jpg', 571, 381, 42520, '0', 0, 0, 0, '1', , '0', 'n' at line 1 Database handle: Resource id #3 Now here is the script: Code: [Select] <?php include("pp-inc.php"); include("login-inc.php"); include("image-inc.php"); if ( is_array($HTTP_POST_FILES) ) { while(list($key,$value) = each($HTTP_POST_FILES)) { ${$key} = $value; } } function handleupload( $location = "data" ) { global $HTTP_POST_FILES, $userid, $Globals, $category; $tmpname = $HTTP_POST_FILES['theimage']['tmp_name']; $realname = $HTTP_POST_FILES['theimage']['name']; $tmpcloseup = $HTTP_POST_FILES['closeup']['tmp_name']; if (is_uploaded_file($tmpname) ) { $realname = fixfilenames( $realname ); $closeup = preg_replace("/(\.[A-Za-z]+)$/", "-closeup\\1", $realname); if ( $location != "data" ) { $dst_file = $location; } else { $dst_file = $Globals{'datafull'}."$category/$userid$realname"; $closeup_file = $Globals{'datafull'}."$category/$userid$closeup"; } copy($tmpname, $dst_file); copy($tmpcloseup, $closeup_file); } else { dieWell("Uploaded file not found: $realname<br>Typical reason is that the file exceeded allowed limits."); exit; } return; } authenticate(); $nolimit = 0; if ( $Globals{'adminnolimit'} == "yes" && $adminedit == 1 ) { $nolimit = 1; } $adminexclude = 0; if ( $Globals{'adminexclude'} == "yes" && $adminedit == 1 ) { $adminexclude = 1; } if ( $adminedit == 0 ) { if ( $Globals{'allowup'} == "no" ) { dieWell( "User uploads not allowed" ); } } $querystring = findenv("QUERY_STRING"); if ( ($useruploads == 0 && $gologin==1) || $querystring == "gologin" ) { $furl=$Globals{'maindir'}; $furl= str_replace( $Globals{'domain'}, "", $furl ); $furl="$furl/uploadphoto.php"; login( $furl ); exit; } if ( $gologin != 0 ) { if ( $useruploads == 0 ) { dieWell("Sorry, you don't have permission to upload photos."); exit; } } topmenu(); if ( !isset($theimage) ) { $catdefault = ""; if ( !empty($cat) ) { $query = "SELECT id,catname,thumbs FROM categories WHERE id=$cat LIMIT 1"; $resultb = ppmysql_query($query,$link); while ( list( $subid, $subcatname, $subthumbs ) = mysql_fetch_row($resultb) ) { if ( $ugcat{$subid} != 1 ) { $catdefault = "<option selected value=\"$subid\">$subcatname</option>"; } } ppmysql_free_result( $resultb ); } $header = str_replace( "titlereplace", "Upload Photo", $header ); $output = "$header<center><p> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" height=\"40\" width=\"".$Globals{'tablewidth'}."\"><Tr> <Td valign=\"middle\" width=\"50%\">$menu2</td> <td width=\"50%\" align=\"right\" valign=\"middle\">$menu</td></tr></table> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"".$Globals{'bordercolor'}."\" width=\"".$Globals{'tablewidth'}."\" align=\"center\"><tr><td> <table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"100%\"> <tr align=\"center\"> <td colspan=\"1\" align=\"left\" bgcolor=\"".$Globals{'headcolor'}."\"><font face=\"".$Globals{'headfont'}."\" color=\"".$Globals{'headfontcolor'}."\" size=\"".$Globals{'fontmedium'}."\"><B>".$Globals{'galleryname'}." Image Upload</font></td> <td colspan=\"1\" align=\"right\" bgcolor=\"".$Globals{'headcolor'}."\"><font face=\"".$Globals{'mainfonts'}."\" color=\"".$Globals{'headfontcolor'}."\" size=\"".$Globals{'fontmedium'}."\"> <a href=\"javascript:PopUpHelp('uploadphoto.php')\">help</a></font> </td> </tr> <form method=\"post\" action=\"".$Globals{'maindir'}."/uploadphoto.php\" enctype=\"multipart/form-data\"> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" face=\"".$Globals{'mainfonts'}."\" color=\"".$Globals{'maintext'}."\">Username</font></td><td bgcolor=\"".$Globals{'maincolor'}."\"> <font size=\"".$Globals{'fontmedium'}."\" face=\"".$Globals{'mainfonts'}."\" color=\"".$Globals{'maintext'}."\">$username</td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\" width=\"50%\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">Choose a category</font></td><Td bgcolor=\"".$Globals{'maincolor'}."\"><select name=\"category\">$catdefault"; if (empty($subid)) $subid=""; $selected = $subid; catmoveopt(0); $output .= $catoptions; $imgdir = $Globals{'zipuploaddir'}."/$userid"; $skiphtml = "</table><table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\"> <tr><Td bgcolor=\"".$Globals{'headcolor'}."\" align=\"center\"> <font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'headfontcolor'}."\" face=\"".$Globals{'mainfonts'}."\"> <b>ADMIN OPTIONS FOR BULK OR ZIP UPLOADS</b></font> </td> <td align=\"right\" bgcolor=\"".$Globals{'headcolor'}."\"><font face=\"".$Globals{'mainfonts'}."\" color=\"".$Globals{'headfontcolor'}."\" size=\"".$Globals{'fontmedium'}."\"> <a href=\"javascript:PopUpHelp('adminskip.php')\">help</a></font> </td> </tr></table> <table cellpadding=\"4\" cellspacing=\"1\" border=\"0\" width=\"100%\"> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">Skip upload and process the files in your upload directory<br><font size=\"".$Globals{'fontsmall'}."\">Files should already be in: <b>$imgdir</b></td> <td bgcolor=\"".$Globals{'maincolor'}."\" align=\"center\"><input type=\"checkbox\" name=\"skipupload\" value=\"skipupload\"></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">Show thumbnails during processing?</td> <td bgcolor=\"".$Globals{'maincolor'}."\" align=\"center\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\"><select name=\"dthumbs\"><option selected>yes</option><option>no</option></select></font></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">Number of thumbnails to process next?</td> <td bgcolor=\"".$Globals{'maincolor'}."\" align=\"center\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\"><select name=\"numprocess\"><option selected>10</option><option>25</option><option>50</option><option>100</option></select></td></tr>"; $output .= "</select></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" face=\"".$Globals{'mainfonts'}."\" color=\"".$Globals{'maintext'}."\">Photo to upload:</font><br><b><font size=\"".$Globals{'fontsmall'}."\" face=\"".$Globals{'mainfonts'}."\" color=\"red\">$maxfilesize</font></b></td><td bgcolor=\"".$Globals{'maincolor'}."\"><input type=\"file\" name=\"theimage\"></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" face=\"".$Globals{'mainfonts'}."\" color=\"".$Globals{'maintext'}."\">Matching closeup to upload:</font><br><b><font size=\"".$Globals{'fontsmall'}."\" face=\"".$Globals{'mainfonts'}."\" color=\"red\">$maxfilesize</font></b></td><td bgcolor=\"".$Globals{'maincolor'}."\"><input type=\"file\" name=\"closeup\"></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">Enter a title for the photo</td><td bgcolor=\"".$Globals{'maincolor'}."\"><input type=\"text\" name=\"title\"></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">To help users find your photo, please enter a few (up to 10) descriptive keywords (separated by spaces):</td><td bgcolor=\"".$Globals{'maincolor'}."\"><input type=\"text\" name=\"keywords\"></td></tr> <tr><Td bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" color=\"".$Globals{'maintext'}."\" face=\"".$Globals{'mainfonts'}."\">Photo Description</td><td bgcolor=\"".$Globals{'maincolor'}."\"><textarea name=\"desc\" cols=\"30\" rows=\"5\"></textarea></td></tr> $skiphtml <Center> <Tr><Td colspan=\"2\" bgcolor=\"".$Globals{'maincolor'}."\"><font size=\"".$Globals{'fontmedium'}."\" face=\"".$Globals{'mainfonts'}."\"><center> <input type=\"hidden\" name=\"password\" value=\"$password\"> <input type=\"hidden\" name=\"userid\" value=\"$userid\"> <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000000\"> <input type=\"submit\" value=\"Upload/Submit\"> <p><b>When you hit SUBMIT, the file you selected will be uploaded.</b><br></font><font size=\"".$Globals{'fontsmall'}."\" face=\"".$Globals{'mainfonts'}."\"> (Depending on the size of the file and your connection, this may take some time. <b>Please be patient.</b>)</p></font></td></tr></table></td></tr></table><p>".$Globals{'cright'}."$footer"; print $output; } else { if (empty($skipupload)) $skipupload=""; if ( $category == "" ) { dieWell( "You must choose a category before uploading."); exit; } if ( $skipupload == "skipupload" ) { $deftitle = urlencode($title); $defdesc = urlencode($desc); $furl = $Globals{'zipuploadurl'}."/$userid"; forward( $Globals{'maindir'}."/bulkupload.php?ppaction=addphotos&do=preview&photopath=$userid&deftitle=$deftitle&defdesc=$defdesc&defcat=$category&keywords=$keywords&numprocess=$numprocess&dthumbs=$dthumbs&furl=$furl", "Preparing to process image list!" ); exit; } $realname = $HTTP_POST_FILES['theimage']['name']; if ( $realname == "" ) { dieWell( "You need to enter the name of a file to upload! $thevideo / $theimage" ); exit; } $realname = fixfilenames( $realname ); $theext = get_ext( $realname ); $filepath = $Globals{'datafull'}."$category/$userid$realname"; $outfilename = "$userid$realname"; $query = "SELECT userid,bigimage FROM photos where userid=$userid"; $resulta = ppmysql_query($query,$link); while( list( $uid, $bgimage ) = mysql_fetch_row($resulta) ) { if ($uid == $userid && $uid != 0) { if ( $bgimage == $realname ) { dieWell("Sorry, you already uploaded an image called $realname. Try a different name."); exit; } } } ppmysql_free_result($resulta); $title = fixmessage( $title ); $keywords = fixmessage( $keywords ); $desc = fixmessage( $desc ); if ( $category == "notcat" ) { $emessage = "The category you chose is a top level category.<p>Please go back and choose one of its subcategories to upload your image."; dieWell($emessage); } //####// Write the file to a directory ##### //#// Do you wish to allow all file types? yes/no (no capital letters) $allowall = "no"; //#// If the above = "no"; then which is the only extention to allow? //#// Remember to have the LAST 4 characters i.e. .ext if ($realname != "") { $isfilegood = "yes"; if ( $allowall != "yes" ) { if ( !is_image($outfilename) ) { $isfilegood = "no"; } } if ($isfilegood == "yes") { handleupload(); } // // ZIP Uploads for Users // if ( $Globals{'allowzip'} ) { if (strtolower(substr($outfilename,strlen($outfilename) - 4,4)) == ".zip" ) { $filepath = $Globals{'zipuploaddir'}."/$userid"; $filedir = "$filepath/$outfilename"; if ( !file_exists( $filepath ) ) { mkdir( $filepath, 0755 ); chmod( $filepath, 0777 ); } chdir( $filepath ); handleupload( $filedir ); $sys_cmd = $Globals{'zip_command'}." -qq $filedir"; system( $sys_cmd ); unlink( $filedir ); $deftitle = urlencode($title); $defdesc = urlencode($desc); $furl = $Globals{'zipuploadurl'}."/$userid"; if ( empty($numprocess) ) $numprocess = 10; if ( empty($dthumbs) ) $dthumbs = "yes"; forward( $Globals{'maindir'}."/bulkupload.php?ppaction=addphotos&do=preview&photopath=$userid&deftitle=$deftitle&defdesc=$defdesc&defcat=$category&keywords=$keywords&numprocess=$numprocess&dthumbs=$dthumbs&furl=$furl", "Preparing to process image list!" ); exit; } } } if ( file_exists($filepath) ) { $insize = filesize( $filepath ); } else { dieWell("File upload error. Cannot find uploaded file.<br>Path: [$filepath]"); exit; } if ( $isfilegood != "yes" ) { dieWell( "Image must be a .jpg, .gif, .tif or .png file." ); exit; } $thumbsize = create_thumb( $realname, $filepath, $category ); process_image( $realname, $filepath, $category ); $query = "SELECT id FROM photos WHERE userid=$userid AND bigimage='$realname'"; $resulta = ppmysql_query($query,$link); list( $forwardid ) = mysql_fetch_row($resulta); ppmysql_free_result($resulta); if ( empty($forwardid) ) { dieWell( "There was a problem processing your image: $realname.<p>Please notify the System Administrator." ); exit; } forward( $Globals{'maindir'}."/showphoto.php?photo=$forwardid", "Your image was uploaded successfully!" ); } ?> Do Globals need to be on for this to work? Or is there another problem? thanks Paul MOD EDIT: [code] . . . [/code] tags added. I am using the dragdrop functionality on a page which also updates the database.Drag and drop is working fine But i am having difficulty to determine which events to use to update the database. Here is my code
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Sortable - Portlets</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <!--<link rel="stylesheet" href="/resources/demos/style.css">--> <style> body { min-width: 520px; } .interview-questions-column { width: 400px; float: left; padding-bottom: 100px; } .question-bank { width: 500px; float: left; padding-bottom: 100px; } .portlet { margin: 0 1em 1em 0; padding: 0.3em; } .portlet-header { padding: 0.2em 0.3em; margin-bottom: 0.5em; position: relative; } .portlet-toggle { position: absolute; top: 50%; right: 0; margin-top: -8px; } .portlet-content { padding: 0.4em; } .portlet-placeholder { border: 1px dotted black; margin: 0 1em 1em 0; height: 50px; } .sortable { border: 1px solid #eee; width: 95%; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; } .bank-quertion-sotrable { border: 1px solid #eee; width: 150px; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .bank-quertion-sotrable li{ margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 200px; } .ui-state-default { height: 1.5em; line-height: 1.2em; } </style> <script> $(function() { $( ".interview-questions-column" ).sortable({ connectWith: ".interview-questions-column", handle: ".portlet-header", cancel: ".portlet-toggle", placeholder: "portlet-placeholder ui-corner-all" }); $( ".portlet" ) .addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) .find( ".portlet-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "<span class='ui-icon ui-icon-minusthick portlet-toggle'></span>"); $( ".portlet-toggle" ).click(function() { var icon = $( this ); icon.toggleClass( "ui-icon-minusthick ui-icon-plusthick" ); icon.closest( ".portlet" ).find( ".portlet-content" ).toggle(); }); }); $(function() { $( ".sortable" ).sortable({ placeholder: "ui-state-default", connectWith: ".connectedSortable", /*receive: function(event, ui) { // only perform for sub drop downs if($(this).hasClass('question_bank')) { // if the item doesn't have the matching sub class if (!$(this).hasClass($(ui.item).attr('class'))) { // cancel the sortable $(ui.sender).sortable('cancel'); } } alert('receive'); alert(ui.sender.attr("dataid")); alert(ui.sender.toSource()); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); },*/ update: function (event, ui) { //serial = $('#sortableF').sortable('serialize'); var data = $(this).sortable('serialize'); alert(data); //alert('update sortable'); //alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); // POST to server using $.post or $.ajax /*$.ajax({ data: 'test', type: 'POST', url: '/your/url/here' });*/ } }).disableSelection(); }); $(function() { $( ".draggable" ).draggable({ connectToSortable: ".sortable", helper: "clone", /*revert: function(valid) { if(valid) { alert("drop is valid"); //Dropped in a valid location } else { alert("drop is invalid"); //Dropped in an invalid location } // return !valid; return false; }*/ stop: function( event, ui ) { // alert(ui); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); } }); }); $( "ul, li" ).disableSelection(); </script> </head> <body> <div class="interview-questions-column"> <div class="portlet"> <div class="portlet-header">Feeds</div> <div class="portlet-content"> <ul id="sortableF" class="connectedSortable sortable"> <li class="ui-state-default" id="item-1">Item 1</li> <li class="ui-state-default" id="item-2">Item 2</li> <li class="ui-state-default" id="item-3">Item 3</li> <li class="ui-state-default" id="item-4">Item 4</li> <li class="ui-state-default" id="item-5">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">News</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-6">Item 1</li> <li class="ui-state-default" id="item-7">Item 2</li> <li class="ui-state-default" id="item-8">Item 3</li> <li class="ui-state-default" id="item-9">Item 4</li> <li class="ui-state-default" id="item-10">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Shopping</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-11">Item 1</li> <li class="ui-state-default" id="item-12">Item 2</li> <li class="ui-state-default" id="item-13">Item 3</li> <li class="ui-state-default" id="item-14">Item 4</li> <li class="ui-state-default" id="item-15">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Links</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-16">Item 1</li> <li class="ui-state-default" id="item-17">Item 2</li> <li class="ui-state-default" id="item-18">Item 3</li> <li class="ui-state-default" id="item-19">Item 4</li> <li class="ui-state-default" id="item-20">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Images</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-21">Item 1</li> <li class="ui-state-default" id="item-22">Item 2</li> <li class="ui-state-default" id="item-23">Item 3</li> <li class="ui-state-default" id="item-24">Item 4</li> <li class="ui-state-default" id="item-25">Item 5</li> </ul> </div> </div> </div> <div class="question-bank"> <div class="portlet"> <div class="portlet-header">Question bank</div> <div class="portlet-content"> <ul id="question_back" class="connectedSortable bank-quertion-sotrable"> <li class="ui-state-default draggable" id="item-26">Item 1</li> <li class="ui-state-default draggable" id="item-27">Item 2</li> <li class="ui-state-default draggable" id="item-28">Item 3</li> <li class="ui-state-default draggable" id="item-29">Item 4</li> <li class="ui-state-default draggable" id="item-30">Item 5</li> </ul> </div> </div> </div> </body> </html>Basically above code will form few boxes with items(which are actually questions) in it. There is one box on the right side with heading "Question Bank". From the "Question Bank" we can drag the questions to other boxes but can't do the reverse(this is also working). Also we can sort the questions within the box or drag the questions from one box to another. Box heading are the categories and items are questions associated to that categories. What i need is : Event that updates the database when we drag the questions from "Question Bank" to any box on the left side. Please note Questions in the "Question Bank" are pre created coming from database. Event that updates the database when we sort the questions within the box. Event that updates the database when we drag the question from one box to another box. it should also do the sorting for that two boxes. Event that updates the database when we sort the boxes. Here is the JS Fiddle link jsfiddle.net/6o30rrzx Question Bank is comming on the bottom of the page instead of on the right side any advice and suggestions will be greatly appreciated Thank you for reading this post. 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 <?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. 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 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
<? 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); ?> 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> <? } ?> 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> 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"); ?> 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. <?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 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> <? } ?> Why has this code stopped working, i had it working, but now it is not...........It is an update profile page but when i click save, it is trying to post my username to the database instead of the persons I am updating......help!!!!!!!! Code: [Select] <?php } //action: edit user ----------------------------------------------------------------------------- if (isset($_GET['edit']) && isset($_GET['id'])) { $userid = (int) $_GET['id']; if ($userid == 0) { die("Invalid ID provided."); } //execution when completed the edit user form and pressed submit button --------------------- if (isset($_POST['editUser'])) { //validate data ------------------------------------------------------------------------ //check email validation, the function is available at config.php //check both passwords are the same when password fields are not empty //end validate data --------------------------------------------------------------------- //save to database when no errors are detected ------------------------------------------ if (count($error) == 0) { $query = "UPDATE members SET username='".$username."', email='".$email."',name='".$name."', phone='".$phone."',address='".$address."', city='".$city."',state='".$state."', zip='".$zip."',cell='".$cell."', accounttype='".$accounttype."',badges='".$badges."', rank='".$rank."' WHERE userid='".$userid."' "; //update username session if you edit yourself if ($userid == $_SESSION['auth_admin_userid']) { $_SESSION['auth_admin_username'] = $username; } if (mysql_query($query)) { echo "<p><strong>User has been edited and saved to the database.</strong></p>"; } else { echo "<strong>User has NOT been edited and saved into the database. ".mysql_error()."</strong>"; } } } //get user from the database and put data into $_POST variables. $rs = mysql_query("SELECT name, username, phone, address, city, state, zip, cell, email, badges, rank, accounttype FROM members WHERE userid = ".$userid.""); if (mysql_num_rows($rs) == 0) { die("User does not exists!"); } $row = mysql_fetch_assoc($rs); $_POST['name'] = $row['name']; $_POST['username'] = $row['username']; $_POST['phone'] = $row['phone']; $_POST['address'] = $row['address']; $_POST['city'] = $row['city']; $_POST['state'] = $row['state']; $_POST['zip'] = $row['zip']; $_POST['cell'] = $row['cell']; $_POST['email'] = $row['email']; $_POST['badges'] = $row['badges']; $_POST['rank'] = $row['rank']; $_POST['accounttype'] = $row['accounttype']; //if is admin, then $_POST['admin'] exists ?> <div id="TabbedPanels1" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"> <li class="TabbedPanelsTab" tabindex="0">My Info</li> <li class="TabbedPanelsTab" tabindex="0">Merit Badges</li> <li class="TabbedPanelsTab" tabindex="0">Scout Rank</li> </ul> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent"> <form action="admin.php?edit&id=<?php echo $userid;?>" method="post"> <table align="center" cellpadding="8" cellspacing="8"> <tr> <td><div align="right">Name:</div></td> <td> <p><input type="text" name="name" value='<?php echo $_POST['name'];?>' /> <?php echo(isset($error['name']))?$error['name']:"";?></p></td> </tr> <tr> <td>Phone Number:</td> <td><input type="text" name="phone" value='<?php echo $_POST['phone'];?>' /> <?php echo(isset($error['phone']))?$error['phone']:"";?></td> </tr> <tr> <td><div align="right">Address:</div></td> <td><input type="text" name="address" value='<?php echo $_POST['address'];?>' /> <?php echo(isset($error['address']))?$error['address']:"";?></td> </tr> <tr> <td><div align="right">City:</div></td> <td><input type="text" name="city" value='<?php echo $_POST['city'];?>' /> <?php echo(isset($error['city']))?$error['city']:"";?></td> </tr> <tr> <td><div align="right">State:</div></td> <td><input type="text" name="state" value='<?php echo $_POST['state'];?>' /> <?php echo(isset($error['state']))?$error['state']:"";?></td> </tr> <tr> <td><div align="right">Zip Code:</div></td> <td><input type="text" name="zip" value='<?php echo $_POST['zip'];?>' /> <?php echo(isset($error['zip']))?$error['zip']:"";?></td> </tr> <tr> <td><div align="right">Email:</div></td> <td> <p> <input type="text" name="email" value='<?php echo $_POST['email'];?>' /> <?php echo(isset($error['email']))?$error['email']:"";?></p></td> </tr> <tr> <td><div align="right">Cell Phone:</div></td> <td><input type="text" name="cell" value='<?php echo $_POST['cell'];?>' /> <?php echo(isset($error['cell']))?$error['cell']:"";?></td> </tr> <tr> <td class="aaaaaaa" align="right">Username:</td> <td><label for="username"></label> <input type="text" name="username" value='<?php echo $_POST['username'];?>' /> <?php echo(isset($error['username']))?$error['username']:"";?></p> </td> </tr> </table> <p> </p> <input name="editUser" type="submit" value="Save" /> <input type="hidden" name="userid" value="<?php echo $userid; ?>" /> </form> </div> <div class="TabbedPanelsContent"> <label for="badges"></label> <input name="badges" type="text" id="badges" value="<?php echo "$badges"; ?>" /> </div> <div class="TabbedPanelsContent"> <input name="rank" type="text" id="rank" value="<?php echo $rank; ?>" /> </div> </div> </div> <script type="text/javascript"> var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1"); </script> <?php } ?> Hi I cant understand why this code isnt echoing the results. Code: [Select] $ids = $_POST['uid']; $con = mysql_connect("localhost","root",""); mysql_select_db("product", $con); $sqlout = mysql_query("SELECT * FROM product2 WHERE 'ID' IN ('$ids')"); while ($sqlres = mysql_fetch_assoc($sqlout)) { echo $sqlres['filename'] . " " . $sqlres['title']; } mysql_close($con); Anyone got any ideas? Thanks James |