Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi guys, I'm working on a recipe website that stores and displays multiple recipes, ingredients and cooking methods. So far, I've managed to add a new recipe, upload 1 image for the recipe, and save the recipe together with it's image and thumbnail (generated automatically from the image) in a mysql DB. The php code obtains the image name when uploading the image, creates a new folder for the image with the same name as the image (to allow multiple images for 1 recipe to be stored). The code is as shown below: <?php $mysql_link = mysql_connect("localhost", "root", ""); mysql_select_db("vyakula") or die("Could not select database"); //include('functions.php'); if(!isset($_SESSION)) { session_start(); $id = $_SESSION['id']; } //error_reporting(0); if (isset($_POST['Upload'])) { // define the posted file into variables $name = $_FILES['file']['name']; $tmp_name = $_FILES['file']['tmp_name']; $type = $_FILES['file']['type']; $size = $_FILES['file']['size']; $oldname = pathinfo($name); $newname = $oldname['filename']; mkdir("images/recipes/$newname", 0700); //if file is empty, return error if((empty($name))) { echo "You have not selected an image!!"; ?> <a href="test.php" title="Add a Photo" onclick="Modalbox.show(this.href, {title: this.title}); return false;">Go Back</a> and try again. <?php die(); } // if the mime type is anything other than what we specify below, kill it if(!($type=='image/pjpeg' OR $type=='image/gif' OR $type=='image/png' OR $type=='image/jpeg')) { echo "'".$type."' is not an acceptable image format."; ?> <a href="test.php" title="Add a Photo" onclick="Modalbox.show(this.href, {title: this.title}); return false;">Go Back</a> and try again. <?php die(); } // if the file size is larger than 4 MB, kill it if($size>'4194304') { echo $name . " is over 4MB. Please make it smaller."; ?> <a href="test.php" title="Add a Photo" onclick="Modalbox.show(this.href, {title: this.title}); return false;">Go back</a> and try again. <?php die(); } // if your server has magic quotes turned off, add slashes manually if(!get_magic_quotes_gpc()){ $name = addslashes($name); } // open up the file and extract the data/content from it $extract = fopen($tmp_name, 'r'); $content = fread($extract, $size); $content = addslashes($content); fclose($extract); //move to folder on server $uploadDir = "images/recipes/$newname/"; $filePath = $uploadDir . $name; $result = move_uploaded_file($tmp_name, $filePath); if (!$result) { echo "Error uploading file"; exit; } $query_photo = "insert into temp_pics (name,size,type,content) values ('$name', '$size','$type','$content')"; if (!mysql_query($query_photo)) { die('Error: ' . mysql_error()); } $pic_id = mysql_insert_id(); //Get latest created row $get_photo = mysql_query("Select * from temp_pics WHERE id='$pic_id'") or die(mysql_error()); $result_get = mysql_fetch_assoc($get_photo); //Create thumbnail $pathToImages = "./images/recipes/$newname/"; // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if (( strtolower($info['extension']) == 'jpg' ) || ( strtolower($info['extension']) == 'png' ) || ( strtolower($info['extension']) == 'gif' )) { $pathToThumbs = "./images/recipes/thumbs/"; //echo "Creating thumbnail for {$fname} <br />"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $thumbWidth = '175'; $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width,$new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); $thumbimage = $fname; } } // close the directory closedir( $dir ); /* print $thumbimage; die(); */ $update_photo = mysql_query("UPDATE temp_pics SET thumb_name='$thumbimage' WHERE id='$pic_id'") or die(mysql_error()); header("Location: new_recipe.php?pic"); } ?> I have 2 resulting problems: 1. I'm not sure how to call the image when displaying it on the site, since the recipe name and the image name are different. Moreso, I wanted to have a gallery where the thumbnails are displayed. This works fine, but I wanted to call the larger images when a thumbnail is clicked on. How will I be able to scroll through the folder and get the larger image from the thumbnail? (Thumbnails have been stored in a separate thumbnails folder, which is contained within the larger recipes folder). 2. If another user wants to add another image for the same recipe, how will I make it so that the uploaded image will be saved to the specific recipe folder (which already exists)?? I would appreciate your feedback. Thanks!!
  2. I have following code block for a tic-tac-toe's game. Please help me simplifying it. $grid=array(); $grid[0]=array(' ',' ',' '); $grid[1]=array(' ',' ',' '); $grid[2]=array(' ',' ',' '); $user='X'; $com='O'; $ran=0; //For user if(($grid[0][1]==$grid[0][2])&&$grid[0][1]!=' '&&$grid[0][0]==' '){$ran=1;} if(($grid[1][0]==$grid[2][0])&&$grid[1][0]!=' '&&$grid[0][0]==' '){$ran=1;} if(($grid[1][1]==$grid[2][2])&&$grid[1][1]!=' '&&$grid[0][0]==' '){$ran=1;} if(($grid[0][0]==$grid[0][2])&&$grid[0][0]!=' '&&$grid[0][1]==' '){$ran=2;} if(($grid[1][1]==$grid[2][1])&&$grid[1][1]!=' '&&$grid[0][1]==' '){$ran=2;} if(($grid[0][0]==$grid[0][1])&&$grid[0][0]!=' '&&$grid[0][2]==' '){$ran=3;} if(($grid[1][1]==$grid[2][0])&&$grid[1][1]!=' '&&$grid[0][2]==' '){$ran=3;} if(($grid[1][2]==$grid[2][2])&&$grid[1][2]!=' '&&$grid[0][2]==' '){$ran=3;} if(($grid[0][0]==$grid[2][0])&&$grid[0][0]!=' '&&$grid[1][0]==' '){$ran=4;} if(($grid[1][1]==$grid[1][2])&&$grid[1][1]!=' '&&$grid[1][0]==' '){$ran=4;} if(($grid[0][0]==$grid[2][2])&&$grid[0][0]!=' '&&$grid[1][1]==' '){$ran=5;} if(($grid[0][1]==$grid[2][1])&&$grid[0][1]!=' '&&$grid[1][1]==' '){$ran=5;} if(($grid[0][2]==$grid[2][0])&&$grid[0][2]!=' '&&$grid[1][1]==' '){$ran=5;} if(($grid[1][0]==$grid[1][2])&&$grid[1][0]!=' '&&$grid[1][1]==' '){$ran=5;} if(($grid[0][2]==$grid[2][2])&&$grid[0][2]!=' '&&$grid[1][2]==' '){$ran=6;} if(($grid[1][0]==$grid[1][1])&&$grid[1][0]!=' '&&$grid[1][2]==' '){$ran=6;} if(($grid[0][0]==$grid[1][0])&&$grid[0][0]!=' '&&$grid[2][0]==' '){$ran=7;} if(($grid[0][2]==$grid[1][1])&&$grid[0][2]!=' '&&$grid[2][0]==' '){$ran=7;} if(($grid[2][1]==$grid[2][2])&&$grid[2][1]!=' '&&$grid[2][0]==' '){$ran=7;} if(($grid[0][1]==$grid[1][1])&&$grid[0][1]!=' '&&$grid[2][1]==' '){$ran=8;} if(($grid[2][0]==$grid[2][2])&&$grid[2][0]!=' '&&$grid[2][1]==' '){$ran=8;} if(($grid[0][0]==$grid[1][1])&&$grid[0][0]!=' '&&$grid[2][2]==' '){$ran=9;} if(($grid[0][2]==$grid[1][2])&&$grid[0][2]!=' '&&$grid[2][2]==' '){$ran=9;} if(($grid[2][0]==$grid[2][1])&&$grid[2][0]!=' '&&$grid[2][2]==' '){$ran=9;} //For computer if(($grid[0][1]==$grid[0][2])&&$grid[0][1]==$com&&$grid[0][0]==' '){$ran=1;} if(($grid[1][0]==$grid[2][0])&&$grid[1][0]==$com&&$grid[0][0]==' '){$ran=1;} if(($grid[1][1]==$grid[2][2])&&$grid[1][1]==$com&&$grid[0][0]==' '){$ran=1;} if(($grid[0][0]==$grid[0][2])&&$grid[0][0]==$com&&$grid[0][1]==' '){$ran=2;} if(($grid[1][1]==$grid[2][1])&&$grid[1][1]==$com&&$grid[0][1]==' '){$ran=2;} if(($grid[0][0]==$grid[0][1])&&$grid[0][0]==$com&&$grid[0][2]==' '){$ran=3;} if(($grid[1][2]==$grid[2][2])&&$grid[1][2]==$com&&$grid[0][2]==' '){$ran=3;} if(($grid[1][1]==$grid[2][0])&&$grid[1][1]==$com&&$grid[0][2]==' '){$ran=3;} if(($grid[1][1]==$grid[1][2])&&$grid[1][1]==$com&&$grid[1][0]==' '){$ran=4;} if(($grid[0][0]==$grid[2][0])&&$grid[0][0]==$com&&$grid[1][0]==' '){$ran=4;} if(($grid[1][0]==$grid[1][2])&&$grid[1][0]==$com&&$grid[1][1]==' '){$ran=5;} if(($grid[0][1]==$grid[2][1])&&$grid[0][1]==$com&&$grid[1][1]==' '){$ran=5;} if(($grid[0][0]==$grid[2][2])&&$grid[0][0]==$com&&$grid[1][1]==' '){$ran=5;} if(($grid[0][2]==$grid[2][0])&&$grid[0][2]==$com&&$grid[1][1]==' '){$ran=5;} if(($grid[1][0]==$grid[1][1])&&$grid[1][0]==$com&&$grid[1][2]==' '){$ran=6;} if(($grid[0][2]==$grid[2][2])&&$grid[0][2]==$com&&$grid[1][2]==' '){$ran=6;} if(($grid[2][1]==$grid[2][2])&&$grid[2][1]==$com&&$grid[2][0]==' '){$ran=7;} if(($grid[0][0]==$grid[1][0])&&$grid[0][0]==$com&&$grid[2][0]==' '){$ran=7;} if(($grid[0][2]==$grid[1][1])&&$grid[0][2]==$com&&$grid[2][0]==' '){$ran=7;} if(($grid[2][0]==$grid[2][2])&&$grid[2][0]==$com&&$grid[2][1]==' '){$ran=8;} if(($grid[0][1]==$grid[1][1])&&$grid[0][1]==$com&&$grid[2][1]==' '){$ran=8;} if(($grid[0][1]==$grid[1][1])&&$grid[0][1]==$com&&$grid[2][1]==' '){$ran=8;} if(($grid[2][0]==$grid[2][1])&&$grid[2][0]==$com&&$grid[2][2]==' '){$ran=9;} if(($grid[0][2]==$grid[1][2])&&$grid[0][2]==$com&&$grid[2][2]==' '){$ran=9;} if(($grid[0][0]==$grid[1][1])&&$grid[0][0]==$com&&$grid[2][2]==' '){$ran=9;} return $ran; Here grid is an 2d array of game's grid and ran is the next position of computer's move. 1 for [0][0], 2 for [0][1],....,8 for [2][1] and 9 for [2][2] The code is working fine but need to reduce it.
  3. So basically want to have a search box and I want users to type in a name and then hit search. It then needs to search through multiple JSON files(11,480) to be precise. I want it to find the name inside the JSON and then pull other information from that JSON file. ATM I only have it where you put in the json file and then it reads the data. The code I currently have is; <?php $string = file_get_contents("2.json"); $json_a=json_decode($string,true); echo "First Name: ", $json_a['Item'][FirstName]; echo "<br>Surname: ", $json_a['Item'][LastName]; echo "<Br>Height: ", $json_a['Item'][Height], "cm"; echo "<br>Rating: ", $json_a['Item'][Rating], " OVRL"; echo "<br>Pace: ", $json_a['Item'][Attribute1]; echo "<br>Shooting: ", $json_a['Item'][Attribute2]; echo "<br>Passing: ", $json_a['Item'][Attribute3]; echo "<br>Dribbling: ", $json_a['Item'][Attribute4]; echo "<br>Defending: ", $json_a['Item'][Attribute5]; echo "<br>Heading: ", $json_a['Item'][Attribute6]; ?> Thanks
  4. So I am using this legacy application which is in php 4. I am trying to set the httponly flag and secure flag on. This is my code: header( "Set-Cookie:". $cookieName."=".$sessId."; expires=".$expireSeconds."; sessionID=".$sessId.";path=".$path."; domain=".$domain."; httponly; secure"); When I test it, The secure flag is set on but the httponly is not. Could it because the URL uses https protocol? Also, does the expire field take seconds. right now, $expireSeconds=14400; How do I modify the code to rectify this if it doesnt expect seconds as a parameter.
  5. i'm building a project for the first time with PDO this is how i configured it index.php <?php require_once (dirname(__FILE__) . '/inc/main.php'); userlogin(); $HTMLOUT = ''; $stmt = $db->query("SELECT row_id, name, mobile FROM location LIMIT 3"); // $stmt->execute(array($id, $name)); $stmt->setFetchMode(PDO::FETCH_OBJ); $db = null; $stmt = null; ?> inc/main.php <?php require_once (dirname(__FILE__) . '/pdo_conn.php'); require_once (dirname(__FILE__) . '/mail/class.Mail.php'); error_reporting(E_ALL); function userlogin() { global $db; unset($GLOBALS["CURUSER"]); $ip = getip(); $nip = ip2long($ip); $id = 0 + get_cookie('uid'); $fetch_user_details = $db->prepare("SELECT * FROM users WHERE user_id = :bitches_id LIMIT 1"); $fetch_user_details->bindParam(':bitches_id', $id, PDO::PARAM_INT); $fetch_user_details->execute(); $fetch_user_details->setFetchMode(PDO::FETCH_OBJ); $row = $fetch_user_details->fetch(); $user_id = $row->user_id; $user_ip = $row->user_last_ip; $update_user_details = $db->prepare("UPDATE users SET user_last_access = UNIX_TIMESTAMP(), user_last_ip = :last_ip WHERE user_id = :u_id LIMIT 1"); $update_user_details->bindParam(':last_ip', $user_ip, PDO::PARAM_STR, 15); $update_user_details->bindParam(':u_id', $user_id, PDO::PARAM_INT); $update_user_details->execute(); $GLOBALS["CURUSER"] = $row; } function is_logged_in() { global $CURUSER; if (!$CURUSER) { header("Location: domain.net/login.php?403"); exit(); } } ?> inc/pdo_conn.php <?php $db = new PDO('mysql:host=localhost;dbname=abc;charset=UTF-8', 'abc', 'xam'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); ?> until a few days ago it worked, but when i starting to expand my project i started to get this error PHP Fatal error: Call to a member function prepare() on a non-object in /root/inc/main.php" the error reffers to this line $fetch_user_details = $db->prepare("SELECT * FROM users WHERE user_id = :bitches_id LIMIT 1");
  6. Hi guys, Been a while since I posted on the forums (if at all). Have an issue that's been biting me for about two days. It's probably staring me in the face though. I can display data from MySQL with PHP on the page just fine. However, updating the database via a form is just not happening. The form just reverts to display the data that was manually entered into the database or the database table is emptied upon submit. Here is the PHP being used to retrieve and update: // Update Database Tables $result = mysql_query("UPDATE `dev_cms`.`settings` SET `site_name` = '$site_name', `site_slogan` = '$site_slogan', `admin_email` = '$admin_email', `facebook` = '$facebook', `twitter` = '$twitter', `tos` = '$tos' WHERE `settings`.`id` =1;"); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM settings") or die(mysql_error()); // store the record of the settings table into $row $row = mysql_fetch_array( $result ); The form: <form action="settings.php" method="post"> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th class="full" colspan="2">General Settings</th> </tr> <tr> <td width="172"><strong>Site Name</strong></td> <td><input type="text" name="site_name" class="text" value="<?php echo $row['site_name']; ?>"/> <i>Your website Name</i></td> </tr> <tr> <td><strong>Site Slogan</strong></td> <td><input type="text" name="site_slogan" class="text" value="<?php echo $row['site_slogan']; ?>"/> <i>A catchy slogan</i></td> </tr> <tr> <td><strong>Admin Email</strong></td> <td><input type="text" name="admin_email" class="text" value="<?php echo $row['admin_email']; ?>"/> <i>For outgoing email</i></td> </tr> <tr> <td><strong>Facebook Page</strong></td> <td><input type="text" name="facebook" class="text" value="<?php echo $row['facebook']; ?>"/> <i>Your Facebook address</i></td> </tr> <tr> <td><strong>Twitter ID</strong></td> <td><input type="text" name="twitter" class="text" value="<?php echo $row['twitter']; ?>"/> <i>Your Twitter ID</i></td> </tr> <tr> <td><strong>Terms of Service</strong></td> <td><textarea name="tos" border="0" cols="45" rows="5"><?php echo $row['tos']; ?> </textarea><i>Terms and Conditions</i></td> </tr> <tr> <td> <label> <input type="submit" name="Submit" value="Save" /> </label></td> </tr> </table> </form> If anyone could please, without too much Jargon, have a look and point me in the right direction I would greatly appreciate it. Thanks in advance.
  7. I am trying to help my mom with her site and we came across a problem with a Excel Page. My mom had information in a Excel document then clicked somewhere in Excel to make it into a webpage. It made it into a .htm page and when I go to add php to it for the layout it doesn't work - It just shows the layout then and no info. Here is the page coding (Internments.htm): <?php $pagetitle = "Saint Michaels Cemetery"; include("../layout/header.php"); ECHO <<<END <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta name="Excel Workbook Frameset"> <meta http-equiv=Content-Type content="text/html; charset=us-ascii"> <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 12"> <link rel=File-List href="Internments_files/filelist.xml"> <![if !supportTabStrip]> <link id="shLink" href="Internments_files/sheet001.htm"> <link id="shLink" href="Internments_files/sheet002.htm"> <link id="shLink" href="Internments_files/sheet003.htm"> <link id="shLink"> <script language="Javascript"> <!-- var c_lTabs=3; var c_rgszSh=new Array(c_lTabs); c_rgszSh[0] = "Sheet1"; c_rgszSh[1] = "Sheet2"; c_rgszSh[2] = "Sheet3"; var c_rgszClr=new Array(; c_rgszClr[0]="window"; c_rgszClr[1]="buttonface"; c_rgszClr[2]="windowframe"; c_rgszClr[3]="windowtext"; c_rgszClr[4]="threedlightshadow"; c_rgszClr[5]="threedhighlight"; c_rgszClr[6]="threeddarkshadow"; c_rgszClr[7]="threedshadow"; var g_iShCur; var g_rglTabX=new Array(c_lTabs); function fnGetIEVer() { var ua=window.navigator.userAgent var msie=ua.indexOf("MSIE") if (msie>0 && window.navigator.platform=="Win32") return parseInt(ua.substring(msie+5,ua.indexOf(".", msie))); else return 0; } function fnBuildFrameset() { var szHTML="<frameset rows=\"*,18\" border=0 width=0 frameborder=no framespacing=0>"+ "<frame src=\""+document.all.item("shLink")[0].href+"\" name=\"frSheet\" noresize>"+ "<frameset cols=\"54,*\" border=0 width=0 frameborder=no framespacing=0>"+ "<frame src=\"\" name=\"frScroll\" marginwidth=0 marginheight=0 scrolling=no>"+ "<frame src=\"\" name=\"frTabs\" marginwidth=0 marginheight=0 scrolling=no>"+ "</frameset></frameset><plaintext>"; with (document) { open("text/html","replace"); write(szHTML); close(); } fnBuildTabStrip(); } function fnBuildTabStrip() { var szHTML= "<html><head><style>.clScroll {font:8pt Courier New;color:"+c_rgszClr[6]+";cursor:default;line-height:10pt;}"+ ".clScroll2 {font:10pt Arial;color:"+c_rgszClr[6]+";cursor:default;line-height:11pt;}</style></head>"+ "<body onclick=\"event.returnValue=false;\" ondragstart=\"event.returnValue=false;\" onselectstart=\"event.returnValue=false;\" bgcolor="+c_rgszClr[4]+" topmargin=0 leftmargin=0><table cellpadding=0 cellspacing=0 width=100%>"+ "<tr><td colspan=6 height=1 bgcolor="+c_rgszClr[2]+"></td></tr>"+ "<tr><td style=\"font:1pt\"> <td>"+ "<td valign=top id=tdScroll class=\"clScroll\" onclick=\"parent.fnFastScrollTabs(0);\" onmouseover=\"parent.fnMouseOverScroll(0);\" onmouseout=\"parent.fnMouseOutScroll(0);\"><a>«</a></td>"+ "<td valign=top id=tdScroll class=\"clScroll2\" onclick=\"parent.fnScrollTabs(0);\" ondblclick=\"parent.fnScrollTabs(0);\" onmouseover=\"parent.fnMouseOverScroll(1);\" onmouseout=\"parent.fnMouseOutScroll(1);\"><a>&lt</a></td>"+ "<td valign=top id=tdScroll class=\"clScroll2\" onclick=\"parent.fnScrollTabs(1);\" ondblclick=\"parent.fnScrollTabs(1);\" onmouseover=\"parent.fnMouseOverScroll(2);\" onmouseout=\"parent.fnMouseOutScroll(2);\"><a>&gt</a></td>"+ "<td valign=top id=tdScroll class=\"clScroll\" onclick=\"parent.fnFastScrollTabs(1);\" onmouseover=\"parent.fnMouseOverScroll(3);\" onmouseout=\"parent.fnMouseOutScroll(3);\"><a>»</a></td>"+ "<td style=\"font:1pt\"> <td></tr></table></body></html>"; with (frames['frScroll'].document) { open("text/html","replace"); write(szHTML); close(); } szHTML = "<html><head>"+ "<style>A:link,A:visited,A:active {text-decoration:none;"+"color:"+c_rgszClr[3]+";}"+ ".clTab {cursor:hand;background:"+c_rgszClr[1]+";font:9pt Arial;padding-left:3px;padding-right:3px;text-align:center;}"+ ".clBorder {background:"+c_rgszClr[2]+";font:1pt;}"+ "</style></head><body onload=\"parent.fnInit();\" onselectstart=\"event.returnValue=false;\" ondragstart=\"event.returnValue=false;\" bgcolor="+c_rgszClr[4]+ " topmargin=0 leftmargin=0><table id=tbTabs cellpadding=0 cellspacing=0>"; var iCellCount=(c_lTabs+1)*2; var i; for (i=0;i<iCellCount;i+=2) szHTML+="<col width=1><col>"; var iRow; for (iRow=0;iRow<6;iRow++) { szHTML+="<tr>"; if (iRow==5) szHTML+="<td colspan="+iCellCount+"></td>"; else { if (iRow==0) { for(i=0;i<iCellCount;i++) szHTML+="<td height=1 class=\"clBorder\"></td>"; } else if (iRow==1) { for(i=0;i<c_lTabs;i++) { szHTML+="<td height=1 nowrap class=\"clBorder\"> </td>"; szHTML+= "<td id=tdTab height=1 nowrap class=\"clTab\" onmouseover=\"parent.fnMouseOverTab("+i+");\" onmouseout=\"parent.fnMouseOutTab("+i+");\">"+ "<a href=\""+document.all.item("shLink")[i].href+"\" target=\"frSheet\" id=aTab> "+c_rgszSh[i]+" </a></td>"; } szHTML+="<td id=tdTab height=1 nowrap class=\"clBorder\"><a id=aTab> </a></td><td width=100%></td>"; } else if (iRow==2) { for (i=0;i<c_lTabs;i++) szHTML+="<td height=1></td><td height=1 class=\"clBorder\"></td>"; szHTML+="<td height=1></td><td height=1></td>"; } else if (iRow==3) { for (i=0;i<iCellCount;i++) szHTML+="<td height=1></td>"; } else if (iRow==4) { for (i=0;i<c_lTabs;i++) szHTML+="<td height=1 width=1></td><td height=1></td>"; szHTML+="<td height=1 width=1></td><td></td>"; } } szHTML+="</tr>"; } szHTML+="</table></body></html>"; with (frames['frTabs'].document) { open("text/html","replace"); charset=document.charset; write(szHTML); close(); } } function fnInit() { g_rglTabX[0]=0; var i; for (i=1;i<=c_lTabs;i++) with (frames['frTabs'].document.all.tbTabs.rows[1].cells[fnTabToCol(i-1)]) g_rglTabX[i]=offsetLeft+offsetWidth-6; } function fnTabToCol(iTab) { return 2*iTab+1; } function fnNextTab(fDir) { var iNextTab=-1; var i; with (frames['frTabs'].document.body) { if (fDir==0) { if (scrollLeft>0) { for (i=0;i<c_lTabs&&g_rglTabX[i]<scrollLeft;i++); if (i<c_lTabs) iNextTab=i-1; } } else { if (g_rglTabX[c_lTabs]+6>offsetWidth+scrollLeft) { for (i=0;i<c_lTabs&&g_rglTabX[i]<=scrollLeft;i++); if (i<c_lTabs) iNextTab=i; } } } return iNextTab; } function fnScrollTabs(fDir) { var iNextTab=fnNextTab(fDir); if (iNextTab>=0) { frames['frTabs'].scroll(g_rglTabX[iNextTab],0); return true; } else return false; } function fnFastScrollTabs(fDir) { if (c_lTabs>16) frames['frTabs'].scroll(g_rglTabX[fDir?c_lTabs-1:0],0); else if (fnScrollTabs(fDir)>0) window.setTimeout("fnFastScrollTabs("+fDir+");",5); } function fnSetTabProps(iTab,fActive) { var iCol=fnTabToCol(iTab); var i; if (iTab>=0) { with (frames['frTabs'].document.all) { with (tbTabs) { for (i=0;i<=4;i++) { with (rows[i]) { if (i==0) cells[iCol].style.background=c_rgszClr[fActive?0:2]; else if (i>0 && i<4) { if (fActive) { cells[iCol-1].style.background=c_rgszClr[2]; cells[iCol].style.background=c_rgszClr[0]; cells[iCol+1].style.background=c_rgszClr[2]; } else { if (i==1) { cells[iCol-1].style.background=c_rgszClr[2]; cells[iCol].style.background=c_rgszClr[1]; cells[iCol+1].style.background=c_rgszClr[2]; } else { cells[iCol-1].style.background=c_rgszClr[4]; cells[iCol].style.background=c_rgszClr[(i==2)?2:4]; cells[iCol+1].style.background=c_rgszClr[4]; } } } else cells[iCol].style.background=c_rgszClr[fActive?2:4]; } } } with (aTab[iTab].style) { cursor=(fActive?"default":"hand"); color=c_rgszClr[3]; } } } } function fnMouseOverScroll(iCtl) { frames['frScroll'].document.all.tdScroll[iCtl].style.color=c_rgszClr[7]; } function fnMouseOutScroll(iCtl) { frames['frScroll'].document.all.tdScroll[iCtl].style.color=c_rgszClr[6]; } function fnMouseOverTab(iTab) { if (iTab!=g_iShCur) { var iCol=fnTabToCol(iTab); with (frames['frTabs'].document.all) { tdTab[iTab].style.background=c_rgszClr[5]; } } } function fnMouseOutTab(iTab) { if (iTab>=0) { var elFrom=frames['frTabs'].event.srcElement; var elTo=frames['frTabs'].event.toElement; if ((!elTo) || (elFrom.tagName==elTo.tagName) || (elTo.tagName=="A" && elTo.parentElement!=elFrom) || (elFrom.tagName=="A" && elFrom.parentElement!=elTo)) { if (iTab!=g_iShCur) { with (frames['frTabs'].document.all) { tdTab[iTab].style.background=c_rgszClr[1]; } } } } } function fnSetActiveSheet(iSh) { if (iSh!=g_iShCur) { fnSetTabProps(g_iShCur,false); fnSetTabProps(iSh,true); g_iShCur=iSh; } } window.g_iIEVer=fnGetIEVer(); if (window.g_iIEVer>=4) fnBuildFrameset(); //--> </script> <![endif]><!--[if gte mso 9]><xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name>Sheet1</x:Name> <x:WorksheetSource HRef="Internments_files/sheet001.htm"/> </x:ExcelWorksheet> <x:ExcelWorksheet> <x:Name>Sheet2</x:Name> <x:WorksheetSource HRef="Internments_files/sheet002.htm"/> </x:ExcelWorksheet> <x:ExcelWorksheet> <x:Name>Sheet3</x:Name> <x:WorksheetSource HRef="Internments_files/sheet003.htm"/> </x:ExcelWorksheet> </x:ExcelWorksheets> <x:Stylesheet HRef="Internments_files/stylesheet.css"/> <x:WindowHeight>9120</x:WindowHeight> <x:WindowWidth>11355</x:WindowWidth> <x:WindowTopX>480</x:WindowTopX> <x:WindowTopY>60</x:WindowTopY> <x:ProtectStructure>False</x:ProtectStructure> <x:ProtectWindows>False</x:ProtectWindows> </x:ExcelWorkbook> </xml><![endif]--> </head> <frameset rows="*,39" border=0 width=0 frameborder=no framespacing=0> <frame src="Internments_files/sheet001.htm" name="frSheet"> <frame src="Internments_files/tabstrip.htm" name="frTabs" marginwidth=0 marginheight=0> <noframes> <body> <p>This page uses frames, but your browser doesn't support them.</p> </body> </noframes> </frameset> </html> END; include("../layout/footer.php"); ?> It works fine without the php stuff. . . but then it doesn't have the layout.
  8. Hello, I am doing a kind of financial calculator which gives you results about the best alternatives to choose from. I do a sql query to the table having the banks data. After that i create a bunch of variables in php and echo the results. These variables are math operations consisting in sql results variables and user input variables. I know how to order sql results, but the problem is that my criteria of sorting is from the php variables created later (which consist of math oparations between sql and user input variables). I have tried sorting it by sql rows....but the dynamic php variables created later are sometimes negatively related to the sql data....so the result does not always get the same. I have an idea like putting the dynamic php variables in an array/arrays and than sorting them according to one of the php variables. But i have no idea how it can be done. Here is a partial code, just to give you an idea of what i mean. <form method="post" action="calc2.php" /> <input name="ss" class="highlight"/> <input class="highlight" name="nn" size="5" /> </form> <?php if (isset($_POST['ss']) && $_POST['nn']>5) { $target = $_POST['ss']; $result = mysql_query("SELECT * FROM list1 WHERE minimum <= {$target} ORDER BY i_rate DESC LIMIT {$number_result}"); if (mysql_num_rows($result) > 0){ while($row = mysql_fetch_array($result)) { $s = $target-$support+$pu+$pv; // according to this variable i want to sort the results, and $pu, $pv are created from user input, which i don't have it here, $traget is sql output. $s is a mix. } } } ?> PLS HEEELP, i have searched everywhere for this and cennot find nothing about exactly what i want.
  9. In a regular form, how would I go about to populate a php session variable with the value of the checkbox the user checked, all without reloading the page? I don't need to error check or anything for this, as I do that once the user submits the form. I just want to add a value to an existing session variable as soon as the user check the box. Any help is greatly appreciated.
  10. <html> <head> <style type="text/css"> /*#pwidget { background-color:lightgray; width:254px; padding:2px; -moz-border-radius:3px; border-radius:3px; text-align:left; border:1px solid gray; }*/ #progressbar { width:30px; padding:1px; background-color:white; border:1px solid black; height:10px; } #indicator { width:0px; background-image:url("shaded-green.png"); height:10px; margin:0; } /*#progressnum { text-align:center; width:250px; }*/ </style> <script type="text/javascript"> function disp_text() { var w = document.myform.mylist.selectedIndex; //alert(w); var selected_text = document.myform.mylist.options[w].value; return selected_text; } function disp_text1() { var x = document.myform1.mylist1.selectedIndex; //alert(x); var second_selected_text = document.myform1.mylist1.selectedIndex; //alert(second_selected_text); return second_selected_text; } var maxprogress = 30 ; // total to reach var actualprogress = 0; // current value var itv = 0; // id to setinterval function prog() { var val = disp_text(); var temp = val; val = maxprogress; maxprogress = temp; if(actualprogress >= maxprogress) { clearInterval(itv); return; } var progressnum = document.getElementById("progressnum"); var indicator = document.getElementById("indicator"); actualprogress += 1; indicator.style.width=actualprogress + "px"; progressnum.innerHTML = actualprogress; if(actualprogress == maxprogress) clearInterval(itv); } </script> </head> <body> <table width="100%"> <tr> <td width="117"><div id="progressbar"> <div id="indicator"></div> </div></td> <td width="78"><div id="pwidget"> <div id="progressnum">0</div> </div></td> <td width="288"> <FORM NAME="myform"> <SELECT NAME="mylist" onchange="disp_text()" class="foo"> <OPTION VALUE="">Select</OPTION> <OPTION VALUE="30">Raghu</OPTION> <OPTION VALUE="45">Vara</OPTION> <OPTION VALUE="60">Sashi</OPTION> </SELECT> </FORM></td></tr><tr> <td width="117"><div id="progressbar"> <div id="indicator"></div> </div></td> <td width="78"><div id="pwidget"> <div id="progressnum">0</div> </div></td><td> <FORM NAME="myform1"> <SELECT NAME="mylist1" onchange="disp_text1()" class="foo"> <OPTION VALUE="">Select</OPTION> <OPTION VALUE="30">Raghu</OPTION> <OPTION VALUE="45">Vara</OPTION> <OPTION VALUE="60">Sashi</OPTION> </SELECT> </FORM> <input type="button" name="Submit" value="Start the progression" onclick="itv = setInterval(prog, 70)" /> </td> <td width="520"> <input type="button" name="Submit2" value="Stop" onclick="clearInterval(itv)" /></td> </tr> <tr> <td> </td> </tr> </table> </body> </html>
  11. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ------- on line 30 <?php include 'dbconfig.php'; echo "<center><big>Inputan Transaksi Jual</big></center>"; if(isset($_GET['action'] ) && ($_GET['action'] == 'delete')){ mysql_query("delete FROM sales where id_sales='".mysql_real_escape_string($_GET['id'])."'"); } $idsales=$_POST['jual']; $namasales=$_POST['sales']; $idbar=$_POST['kd_barang']; $namabar=$_POST['nama_barang']; $jumlahjual=$_POST['jumlah_barang']; $jumlahkembali=$_POST['jumlah_kembali']; $tglambil=$_POST['tanggal_jual']; $sql="insert into transaksijual values('".$_POST."','".$_POST['jual']."','".$_POST['sales']."','".$_POST['kd_barang']."','".$_POST['nama_barang']."','".$_POST['jumlah_barang']."','".$_POST['jumlah_kembali']."','".$_POST['tanggal_jual']."')"; if (! $result=mysql_query($sql, $dbh)) { echo mysql_error(); return 0; } echo "<table border='1'>"; echo "<tr><td>ID Nomor Sales<td>Nama Sales<td>Kode Barang<td>Nama Barang<td>Jumlah Barang<td>Jumlah Kembali<td>Tanggal Jual</tr>"; $sql = "select max(id) as id_sales from sales limit 1"; $row = mysql_fetch_array(mysql_query($sql)); $id_sales = $row['id_sales']; { foreach($_POST['kd_barang'] as $key => $kode){ $sql = "insert into transaksijual(nomor_tjual,id_sales,nama_sales,kd_barang, nama_barang,jumlah_barang,jumlah_kembali,tanggal_jual) values ('{$_POST}','{$_POST['jual']}','{$_POST['sales']}','{$idbar}','{$_POST['nama_barang'][$key]}','{$kode}','{$_POST['jumlah_barang'][$key]}','{$_POST['jumlah_kembali'][$key]}','{$_POST['tanggal_jual'][$key]}')"; mysql_query($sql); } echo 'Data telah disimpan'; echo "<tr>"; echo "<td>".$row[0]; echo "<td>".$row[1]; echo "<td>".$row[2]; echo "<td>".$row[3]; echo "<td>".$row[4]; echo "<td>".$row[5]; echo "<td>".$row[6]; echo "<td>"; echo '<a href="updaterincianjual.php?id='.$row['0'].'">Edit</a>'; echo ' | <a href="simpan-jual.php?id='.$row['0'].'&action=delete">Delete</a>'; echo "</td>"; echo "</tr>"; } echo "</table>"; ?> <html> <body> <form action='welcome.php'> <input type='submit' value='Home'> </form> </body> </html> <?php mysql_close(); ?>
  12. hello, I'm doing a project right now and I'm kinda stuck with this... i am building a page which needs to display text and images from a document in same style(font size and alingment basically) as its in document (like rtf, word or pdf) which user can easily change through available editors . i am getting filename and path from database (Mysql) but i've searched everywhere and got no idea of any way to read file (so far just text from rtf could be read but image is also just all in text, word and pdf give just mess in string) is there any way to do this using PHP or i have to store whole file data in database itself.. or is there anything else i can do to take text and images dynamically to display on required page
  13. I have a question about passing a variable from php to html and back again Ideally i'd like to pass a customers name inputted into php file using a form out into the form submission page as a hidden form input and then use this value in a new php file when a button is pressed to send them back to the home page. the aim is to show the users name once they have completed the form. I've had a look around and many people suggest using code similar to this: value="<?php echo htmlspecialchars($name); ?>" but if i include this in my html form do I not have to save the html document as php? I hope someone can help, thanks in advance!
  14. I am trying to store information sent via a form into a MySQL DB. It doesn't load the next page nor does it store the information. My header requires init.php which I can confirm has the correct database connection credentials. The following is my HTML and "uploader" script - I know it must be something silly but this is where the issue lies, in the html and/or the uploader.php. If someone could run through my code and point out each issue (and possibly a re-work of my code) it would be very much appreciated! Thank you!! HTML (I've reduced the Date of Birth options so there's less code here) <h2>Choose Your File</h2> <form id="submit-photo" action="index.php?p=uploader" enctype="multipart/form-data" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="5242880" /> <div id="FileUpload"> <input type="file" name="photo" id="BrowserHidden" onchange="getElementById('FileField').value = getElementById('BrowserHidden').value;" /> <div id="BrowserVisible"><input type="text" id="FileField" /></div> <span class="error"><?php if(isset($_SESSION['flash_message']['photo'])) echo $_SESSION['flash_message']['photo'] ?> </span></div> <fieldset> <label for="name">Name</label> <input type="text" name="name" id="name"> </fieldset> <fieldset> <label for="dob">DOB</label> <div class="dob-select"> <select name="dob_day" id="dob_day"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> </select> </div> <div class="dob-select"> <select name="dob_month" id="dob_month"> <option value="01">Jan</option> <option value="02">Feb</option> <option value="03">Mar</option> <option value="04">Apr</option> </select> </div> <div class="dob-select"> <select name="dob_year" id="dob_year"> <option value="2012">2012</option> <option value="2011">2011</option> <option value="2010">2010</option> </select> </div> </fieldset> <fieldset> <label for="postcode">Postcode</label> <input type="text" class="short" name="postcode" id="postcode"> </fieldset> <fieldset> <label for="email">Email</label> <input type="email" name="email" id="email"> </fieldset> <fieldset> <label for="subscribe"><input type="checkbox" class="left" id="subscribe"> <p class="left">subscribe</p></label> <input type="submit" name="submit"> </fieldset> </form> DB Columns - id (auto-incremented) - name - photo (path to file) - email - date (date of birth: day, month, year dropdown selectors to be combined to form this) - postcode - subscribe (should be 0 or 1) - approve - created (timestamp) Uploader PHP <?php $error = array(); require_once 'init.php'; //Is request? if(strtolower($_SERVER['REQUEST_METHOD']) == 'post') { //$friend = ( $_POST['friend'] == 'true' ) ? 1 : 0; $required_array = array( 'name' => 'Name', 'dob_day' => 'Day', 'dob_month' => 'Month', 'dob_year' => 'Year', 'postcode' => 'Postcode', 'email' => 'Email Address', 'subscribe' => 'subscribe' ); $required_error = array(); foreach( $required_array as $field_name => $field ) { if(!isset($_POST[$field_name]) OR empty($_POST[$field_name]) OR $_POST[$field_name] == '') { $required_error[$field_name] = 'Please insert your '. $field; } } $_POST['email'] = verify_email($_POST['email']); if($_POST['email'] == FALSE && !isset($error['email'])) $error['email'] = 'Please use a valid email address'; //Validate the form key if(!isset($_POST['form_key']) || !$formKey->validate()) { //Form key is invalid, show an error $error['general'] = 'Use the real form!'; } else { if((!empty($_FILES["photo"])) && ($_FILES['photo']['error'] == 0)) { $filename = basename($_FILES['photo']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); //Check if the file is JPEG image and it's size is less than 5Mb if ( ($ext == "jpg") && ($_FILES["photo"]["type"] == "image/jpeg") && ($_FILES["photo"]["size"] <= 5242880) ) { //Determine the path to which we want to save this file $newname = str_replace( ' ', '_', trim( strip_tags( $_POST['name'] ) ) ) . _ . $formKey->generateKey() . '_' . time() . '.jpg'; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { if (sizeof($required_error) == 0) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['photo']['tmp_name'], './photos/'. $newname))) { $move_status = 'done'; } else { $error['photo'] = "A problem occurred during file upload!"; } } } else { $error['photo'] = "File ".$_FILES["photo"]["name"]." already exists"; } } else { $error['photo'] = "Only .jpg images under 5Mb are accepted for upload". $_FILES["photo"]["size"] . $_FILES["photo"]["type"] . '====' . $ext; } } else { $error['photo'] = "No photo uploaded"; } } $error = $error + $required_error; if (sizeof($error) == 0 AND $move_status == 'done') { $_POST['date'] = $_POST['dob_day'].'-'.$_POST['dob_month'].'-'.$_POST['dob_year']; $query = sprintf("INSERT INTO `$db_name`.`submissionform` (`id` , `name` , `photo` , `email` , `date` , `postcode` , `subscribe` , `approve` , `created` ) VALUES ( NULL , '%s', '%s', '%s', '%s', '%s', '%s', '0', CURRENT_TIMESTAMP );", mysql_real_escape_string($_POST['name']), mysql_real_escape_string($newname), mysql_real_escape_string($_POST['email']), mysql_real_escape_string($_POST['date']), mysql_real_escape_string($_POST['postcode']), mysql_real_escape_string($_POST['subscribe']), mysql_real_escape_string($_POST['approve']), mysql_real_escape_string($_POST['message']) ); mysql_query('SET AUTOCOMMIT=0'); $result1 = mysql_query($query); $last_id = mysql_insert_id(); if ($result1) $success = 'Done'; else $error['general'] = 'Error when submitting your form, please try again.'; //mysql_free_result($result); mysql_close(); } } if ($success == 'Done') { $page = 'uploader'; include 'header.php'; echo '<img height="782" style="float:left;" src="./assets/img/success.png" />'; include 'footer.php'; } else { $_SESSION['flash_message'] = $error; $_SESSION['recent_field'] = $_POST; header('Location: ./index.php'); } ?>
  15. I got a script from somewhere on google and found that it contains a "dynamic div" tag i.e see below <div id="ad<?php echo $fn; ?>"> // [color=#ff0000]This is the place where i'm facing problem...[/color] <a href="index.php?tp=visit_task&t=<?php echo $fn; ?>&id=<?php echo $fn; ?>" target='_blank' onclick='hideDivTag("ad<?php echo $fn; ?>");'><?php echo $fsitename; ?></a> ( You earn: <?php if($fpaytype=='points') { ?><?php echo $prise; ?> <?php echo $setupinfo['pointsName']; ?>(s)<?php } else if($fpaytype=='usd') echo $setupinfo['currency']."$prise"; ?> ) <BR /><BR /></div><?php $clicks++; } } } ?><br /> </div> when this code is seen in browser it looks like this <div id="ad44"> <a href="index.php?tp=visit_task&t=44&id=44" target='_blank' onclick='hideDivTag("ad44");'>Google</a> ( You earn: Rs 0.001000 ) <BR /><BR /></div> <div id="ad45"> // [color=#ff0000]This One[/color] <a href="index.php?tp=visit_task&t=45&id=45" target='_blank' onclick='hideDivTag("ad45");'>156</a> ( You earn: Rs 0.001000 ) <BR /><BR /></div> <div id="ad47">// [color=#ff0000]This One[/color] <a href="index.php?tp=visit_task&t=47&id=47" target='_blank' onclick='hideDivTag("ad47");'>123</a> ( You earn: Rs 0.001000 ) <BR /><BR /></div> <div id="ad49"> //[color=#ff0000]This One[/color] <a href="index.php?tp=visit_task&t=49&id=49" target='_blank' onclick='hideDivTag("ad49");'>789</a> ( You earn: Rs 0.001000 ) <BR /><BR /></div> <div id="ad50"> //[color=#ff0000]This One[/color] <a href="index.php?tp=visit_task&t=50&id=50" target='_blank' onclick='hideDivTag("ad50");'>459</a> ( You earn: Rs 0.001000 ) <BR /><BR /></div><br /> <br /> </div> see that every div tags automatically assigns a number beside it.. I want to add new style of this div but can't do that as it is changing randomly whenever new ads is posted and i also can't find the #ad in the .css also..... can anyone help me.... Thanks in advance...
  16. Hi guys I have the following tables: table: capitulo capitulo_id autoincrement libro_id capitulo table: rv1960 id versiculo texto I have the following code in which i want to populate all the versiculo(vers) and texto from each capitulo(chapter) what i acomplish is populate the vers from all chapters , i just show all vers from each chapter. this is the query i use <?php //variable $versiculo = $_GET['cat']; $query="SELECT versiculo, texto from rv1960 where id = $versiculo"; $result=mysql_query($query); if(mysql_num_rows($result)>0){ echo"<table border='0' align='center' cellpadding='2' cellspacing='2' width='100%'>"; while($row=mysql_fetch_array($result,MYSQL_ASSOC)){ $versiculo = $row['versiculo']; $texto = $row['texto']; echo "<tr>"; echo "<td VALIGN='TOP'><font size='2' color='#FFFFFF' face='Verdana' color='red'>$versiculo</font></td>"; echo"<td VALIGN='TOP'><font size='2' face='Verdana' color='#FFFFFF'>$texto</font></td>"; echo "</tr>"; } echo"</table>"; } ?> can help me pleases thanks
  17. Hi guys, ive got an awkward problem that doesn't seem to want to fix itself no matter how hard i try. Basically, I have in my Database a table called horses and the columns are I then have a php webpage with a dropdown box which is populated from the database. <form action="" method="post" align="center"> <fieldset> <select name="horses" onchange="benSucksDick(this.value)" align="center"> <option value="">Select a Horse</option><Br><br><br> <!-- RUN QUERY TO POPULATE DROP DOWN --> <?php mysql_connect("localhost", "root", "") or die("Connection Failed"); mysql_select_db("horse")or die("Connection Failed"); $query = "SELECT * FROM horses ORDER by ID"; $result = mysql_query($query) or die(mysql_error()); /*$num = mysql_num_rows($result);*/ while($row = mysql_fetch_array($result)) { echo "<option value='".$row['ID']."'>".$row['Name']."</option>"; } ?> </select></fieldset> I also have a AJAX call to edit.php which fetches the data in column web_horse and outputs it to a CKeditor instance. AJAX code <script type="text/javascript"> function benSucksDick(str) { if (str=="") { document.getElementById("maincontent").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("maincontent").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","content/edit.php?q="+str,true); xmlhttp.send(); } </script> edit.php Code <?php error_reporting(-1); // Make sure you are using a correct path here. include 'ckeditor/ckeditor.php'; $ckeditor = new CKEditor(); $ckeditor->basePath = '/ckeditor/'; $ckeditor->config['filebrowserBrowseUrl'] = '/ckfinder/ckfinder.html'; $ckeditor->config['filebrowserImageBrowseUrl'] = '/ckfinder/ckfinder.html?type=Images'; $ckeditor->config['filebrowserFlashBrowseUrl'] = '/ckfinder/ckfinder.html?type=Flash'; $ckeditor->config['filebrowserUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'; $ckeditor->config['filebrowserImageUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'; $ckeditor->config['filebrowserFlashUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'; mysql_connect("localhost", "root", "") or die("Connection Failed"); mysql_select_db("horse")or die("Connection Failed"); $q=$_GET["q"]; $sql="SELECT web_content FROM horses WHERE id = '".$q."'"; $resultab = mysql_query($sql); while($row = mysql_fetch_array($resultab)) { echo $row['web_content']; } ?> Now, the CKeditor initialises when the page is loaded, but when i change the dropdown to a different value from the database it just shows the html code and/or a text area WITHOUT the CKeditor instance. If anyone can help me, that would be grand!!
  18. These are code of my wordpress template page & post page.it's repeating twice.is it looping same code?. please help me to correct the code. (template page) <?php /*?> <?php if(have_posts()): while(have_posts()): the_post(); ?> <h1><?php the_title();?></h1> <p><?php the_content();?></p> <?php endwhile; else : endif;?> <?php */?> (WP Page) <?php */?> <?php query_posts('cat=4&showposts=8'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <a>"><?php the_title()?></a> <?php the_excerpt();?> <?php endwhile; endif; ?> <?php */?>
  19. Hi, I am creating menu using jquery-mega-drop-down-menu-plugin. I am stroing menu items in database and want to create html sturcture dynamically by looping over resultset I have attached working example. Following html need to create dynamically. <li><a href="#">Home</a></li> <li><a href="#">About Us</a> <ul> <li><a href="#">Menu Item 1</a></li> <li><a href="#">Menu Item 2</a></li> </ul> </li> <li><a href="#">Services</a></li> <li><a href="#">Contact us</a></li> Database Table for menu items as follow CREATE TABLE `headermenu` ( `id` int(11) NOT NULL AUTO_INCREMENT, `text` varchar(300) DEFAULT NULL, `parentid` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 Any solution? Thanks for time and efforts in advance. - Thanks Zohaib. menu.zip
  20. Hello all, I've recently installed PHP 5 on my system and am trying to use NetBeans as an IDE, however when I try to configure NetBeans for the PHP 5 Interpreter my system fails to find anything. I've searched through my install directories, and also downloaded and searched the source files but cannot find it anywhere. I've searched google for the file or for answers and cannot find anything that solves the problem, its always some other problem where php pages load fine once, then something happens and they don't load any more. My situation is that they wont' load from the get go, and i cannot find the php interpreter. I've also since then tried to re install php using EasyPHP WAMP. It says that everything was installed successfully but when i try to load the pages from the local host it failes to load because it doesn't have a php interpreter selected... i don't know why either of these IDE's and setups would not install the interpreter or maybe i'm just not getting it.. perhaps it could be as simple as renaming a file and moving it.. i'm not sure and i can't seem to find any help trolling google.. I hope that someone out there can help shed some light on this subject for me, any effort will be greately appreciated. Thanks, Matt
  21. Hello there, i have a table called "category" that haves 2 columns, that are "category" and "category_en" And im echo the list of data that i have, i can make the listins of columns "category appear but not the data of category_en . Take a look in my code please $qry=mysql_query("SELECT * FROM category", $con); if(!$qry) { die("Query Failed: ". mysql_error()); } <?php while($row=mysql_fetch_array($qry)) { echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>"; } ?> <?php while($row=mysql_fetch_array($qry)) { echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>"; } ?>
  22. Hello, I wrote an emailer script to add to my web site. The code seems to be fine and the variables seem to parse, but still I can not send an e-mail. Could you please tell me what am I doing wrong? I think the error is somewhere in the sendEmail function, but a second opinion is always better to have. The code is: <?php class emailer { private $sender; private $subject; private $body; function __construct($sender) { $this->sender = $sender; //$this->recipient = $recipient; } function addSender($sender){ $this->sender = $sender; } function addSubject($subject){ $this->subject = $subject; } function addBody($body){ $this->body = $body; } function sendEmail(){ $this->recipient = 'test@mail.com'; $this->result = mail($this->recipient, $this->subject, $this->body, "From: {$this->sender} \r\n"); if (!$this->result){ echo $this->result; echo $this->recipient; echo $this->sender; echo $this->subject; echo $this->body; echo "Error"; } else{ echo "e-mail was sent."; } } } ?> Thank you in advance. PS. when I execute the script, I get as output "Error", and I also get the data stored in the variables (recipient,sender,subject, and body).
  23. Greetings everyone, I really hope someone would be able to help me quickly... I'm not very clued up on ajax,jquery or javascript, and would really love some help in converting the attached js file to use a database instead of cookies. Please guys, thanx in advance.
  24. Amigos, Coming from desktop applications environment, I have been playing around with PHP for months now, I am so comfortable with it. I understood that frameworks should help me do many things better and faster; I see the benefit, however once I start learning it, I get many problems as I can not see the real base logic behind it and I get lost easily. It seems to me that it is easier to build from the zero in pure PHP, rather than learning a framework, which I can not understand totally. Yii was my choice.. I don't think it has anything to do with the specific choice... Any advice? Did I have a wrong approach ?? Advices about good resources to start with it??? or may be I should just keep it with pure PHP?!??
  25. Hey peoples I need some advice, I am working on converting a forum for someone as a favor. It is a forum with 70,000 topics and almost 1kk posts. I have already figured out how to convert the users to phpbb. Also forum data is extremely dirty. The guy who wrote the software didn't put in any validation. This forum has been going down lately for no reason and I am sure its due to issues with database info / structure. <?PHP $sql = 'SELECT forum_id, forum_name FROM Rabbitry.phpbb_forums WHERE parent_id != 0'; $query = MySQL::query($sql); while($row = mysqli_fetch_array($query)){ $forums_id[$row['forum_id']] = $row['forum_name']; $forum_name[$row['forum_name']] = $row['forum_id']; } $sql = 'SELECT topic_id, forum_id, poll_id, topic_name, topic_description, topic_views, topic_starter_id, topic_date_time FROM ultra.wowbb_topics'; $result = MySQL::query($sql); while($row = mysqli_fetch_array($result)){ foreach($row as $key=>$value){ $row[$key] = MySQL::escape($value); } $row['topic_date_time'] = strtotime($row['topic_date_time']); if($row['topic_date_time'] < 0){ $row['topic_date_time'] = NULL; } if($row['poll_id'] !== 0){ //get poll info } $sql_posts = 'SELECT wowbb_posts.post_id, post_text, attachment_id, user_id, post_date_time, post_ip, post_last_edited_on, post_last_edited_by FROM ultra.wowbb_posts INNER JOIN ultra.wowbb_post_texts USING (post_id) WHERE topic_id = \''.$row['topic_id'].'\''; MySQL::query($sql_posts); ?> I ran this, and it doesn't even have any insert statements and I let it go for 5 -6 minutes and it was still running. Any recommendations would be really appreciated !! I have never done anything this large from a conversion process. Matt
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.