PHP - Unable To Load Image Data
I wonder whether someone may be able to help me please.
I'm trying to put together a PHP within Aurigma Image Uploader which will create an image gallery. To do this I need to extract the image from a folder called 'Thumbnails' and image data from a file called 'files.xml'. The code below is an extract of the default script that performs this functionality and I've tested and it works without any issues. Code: [Select] <?php //This variable specifies relative path to the folder, where the gallery with uploaded files is located. //Do not forget about the slash in the end of the folder name. $galleryPath = 'UploadedFiles/'; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> I have now changed my folder and file structure to the following: UploadedFiles (Folder) username (Subfolder containing the 'location' folder) location (Subfolder containing 'Thumbnails folder and image, and 'files.xml') Please note that both the 'username' and 'location' folders are dynamically created when the user initially uploads the images. To try and accomodate the new file structure I changed my code to: Code: [Select] <?php //This variable specifies relative path to the folder, where the gallery with uploaded files is located. //Do not forget about the slash in the end of the folder name. $galleryPath = 'UploadedFiles/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> But when I run this I receive the following error: Quote d333603417/htdocs/development/UploadedFiles/files.xml" in /homepages/2/d333603417/htdocs/development/gallery.php on line 14 Line 14 is this line: Code: [Select] $descriptions->load($absGalleryPath . 'files.xml'); I've been working on this for days and I just can't seem to find the answer. I just wondered whether someone could possibly look at this and let me know where I'm going wrong. If it helps, I've added the upload script below. Code: [Select] <?php require_once 'Includes/gallery_helper.php'; require_once 'ImageUploaderPHP/UploadHandler.class.php'; $galleryPath = 'UploadedFiles/'; function onFileUploaded($uploadedFile) { global $galleryPath; $packageFields = $uploadedFile->getPackage()->getPackageFields(); $username=$packageFields["username"]; $locationid=$packageFields["locationid"]; $username = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['username']); $location = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['locationid']); $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['folder']); $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $username . DIRECTORY_SEPARATOR . $location . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; if (!is_dir($absGalleryPath)) mkdir($absGalleryPath, 0777, true); chmod($absGalleryPath, 0777); if (!is_dir($absGalleryPath . $dirName)) mkdir($absGalleryPath . $dirName, 0777, true); chmod($absGalleryPath . $dirName, 0777); if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) initGallery($absGalleryPath, $absThumbnailsPath, FALSE); $originalFileName = $uploadedFile->getSourceName(); $files = $uploadedFile->getConvertedFiles(); $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName); $sourceFile = $files[0]; if ($sourceFile) $sourceFile->moveTo($absGalleryPath . $sourceFileName); $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName); $thumbnailFile = $files[1]; if ($thumbnailFile) $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName); $descriptions = new DOMDocument('1.0', 'utf-8'); $descriptions->load($absGalleryPath . 'files.xml'); $xmlFile = $descriptions->createElement('file'); // <-- please check the following line $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName); $xmlFile->setAttribute('source', $sourceFileName); $xmlFile->setAttribute('size', $uploadedFile->getSourceSize()); $xmlFile->setAttribute('originalname', $originalFileName); $xmlFile->setAttribute('thumbnail', $thumbnailFileName); $xmlFile->setAttribute('description', $uploadedFile->getDescription()); $xmlFile->setAttribute('username', $username); $xmlFile->setAttribute('locationid', $locationid); $xmlFile->setAttribute('folder', $dirName); $descriptions->documentElement->appendChild($xmlFile); $descriptions->save($absGalleryPath . 'files.xml'); } $uh = new UploadHandler(); $uh->setFileUploadedCallback('onFileUploaded'); $uh->processRequest(); ?> Many thanks Similar TutorialsI wonder whether someone may be able to help me please. I've put together the following script which saves user defined images to server folders using the Aurigma Image Uploader software. Code: [Select] <?php require_once 'Includes/gallery_helper.php'; require_once 'ImageUploaderPHP/UploadHandler.class.php'; $galleryPath = 'UploadedFiles/'; function onFileUploaded($uploadedFile) { global $galleryPath; $packageFields = $uploadedFile->getPackage()->getPackageFields(); $username=$packageFields["username"]; $locationid=$packageFields["locationid"]; $usernamefolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['username']); $locationfolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['locationid']); $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['folder']); $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; if (!is_dir($absGalleryPath)) mkdir($absGalleryPath, 0777, true); chmod($absGalleryPath, 0777); if (!is_dir($absGalleryPath . $dirName)) mkdir($absGalleryPath . $dirName, 0777, true); chmod($absGalleryPath . $dirName, 0777); if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) initGallery($absGalleryPath, $absThumbnailsPath, FALSE); $originalFileName = $uploadedFile->getSourceName(); $files = $uploadedFile->getConvertedFiles(); $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName); $sourceFile = $files[0]; if ($sourceFile) $sourceFile->moveTo($absGalleryPath . $sourceFileName); $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName); $thumbnailFile = $files[1]; if ($thumbnailFile) $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName); $descriptions = new DOMDocument('1.0', 'utf-8'); $descriptions->load($absGalleryPath . 'files.xml'); $xmlFile = $descriptions->createElement('file'); // <-- please check the following line $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName); $xmlFile->setAttribute('source', $sourceFileName); $xmlFile->setAttribute('size', $uploadedFile->getSourceSize()); $xmlFile->setAttribute('originalname', $originalFileName); $xmlFile->setAttribute('thumbnail', $thumbnailFileName); $xmlFile->setAttribute('description', $uploadedFile->getDescription()); $xmlFile->setAttribute('username', $username); $xmlFile->setAttribute('locationid', $locationid); $xmlFile->setAttribute('folder', $dirName); $descriptions->documentElement->appendChild($xmlFile); $descriptions->save($absGalleryPath . 'files.xml'); } $uh = new UploadHandler(); $uh->setFileUploadedCallback('onFileUploaded'); $uh->processRequest(); ?> This code saves the files in the following structu UploadedFiles (Pre-existing folder) 'username' (Subfolder created dynamically on image upload if it doesn't already exist. This folder contains the 'location' folder) 'location' (Subfolder created dynamically on image upload if it doesn't already exist. This contains original image, 'files.xml' and 'Thumbnails' folder) 'Thumbnails' (Subfolder created dynamically on image upload if it doesn't already exist. This contains thumbnail of original image) I'm now trying to put together a script which creates an image gallery, with those images pertinent to the current user and location. The code below is the piece of my script which deals with the loading of the images. Code: [Select] <?php $galleryPath = 'UploadedFiles/'; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> The initial problem I had, was resolved from guidance I received on this site, and that was to find the correct 'realpath' of the 'Thumbnails' folder and 'files.xml' These are as follows: Quote /homepages/2/d333603417/htdocs/development/UploadedFiles/IRHM73/1 and Quote /homepages/2/d333603417/htdocs/development/UploadedFiles/IRHM73/1/Thumbnails with 'IRHM73' being the 'username' value and '1' the 'location' value. The problem I now have lies within this line of code: `$absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR;` Because the 'username' and 'location' are dynamic and hence contain different values for each user and location, I've found it impossible to find a way of creating the correct file path to open the 'Thumbnails' folder and 'files.xml'. I had tried this: Code: [Select] <?php $galleryPath = 'UploadedFiles/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> But I receive the following error: DOMDocument::load() domdocument.load: I/O warning : failed to load external entity /homepages/2/d333603417/htdocs/development/UploadedFiles/'files.xml'; in /homepages/2/d333603417/htdocs/development/gallery.php on line 13 and line 13 is this: Code: [Select] $descriptions->load($absGalleryPath . 'files.xml'); I really am stumped with what to do next to get this to work. I appreciate that this is a fairly lengthy post, but thought it would be better to post all the information. I just wondered whether someone could perhaps take a look at this and let me know where I'm going wrong and how I can get it to work. Many thanks and regards Hi, I've a simple code which uses a class from here. When I execute it, I get this error QuoteFatal error: Uncaught Error: Class 'phpMQTT' not found in C:\Apache24\htdocs\mqtt\test.php:10 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mqtt\test.php on line 10 and I cannot understand why my code doesn't see the class. Both files, the class.php and test.php, are in the same folder. Any help is appreciated.
TIA <?php require("phpMQTT.php"); $server = "192.168.0.250"; // change if necessary $port = 1883; // change if necessary $username = ""; // set your username $password = ""; // set your password $client_id = "phpMQTT-publisher"; // make sure this is unique for connecting to sever - you could use uniqid() $mqtt = new phpMQTT($server, $port, $client_id); if ($mqtt->connect(true, NULL, $username, $password)) { echo 'hereeeee'; $mqtt->publish("room/lamp", "on" . date("r"), 0); $mqtt->close(); } else { echo "Time out!\n"; } ?>
hi all,
this is my setup
Apache/2.2.15 (Unix)
PHP 5.4.36 (cli) (built: Dec 19 2014 06:28:27)
CentOS release 6.6
i am having intermmittent issues whenever in install pdo_oci and oci8 for PHP following this procedure
http://shiki.me/blog...ntos-6-4-64bit/
this is the full error
[root@localhost ~]# php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - /usr/lib64/php/modules/oci8.so: undefined symbol: php_checkuid in Unknown on line 0 PHP Warning: PHP Startup: PDO_OCI: Unable to initialize module location of oci8 [root@localhost ~]# cd /usr/lib64/php/ [root@localhost php]# ll total 8 drwxr-xr-x. 2 root root 4096 Jan 6 20:16 build drwxr-xr-x. 2 root root 4096 Jan 6 20:16 modules [root@localhost php]# cd modules/ [root@localhost modules]# ll total 4052 -rwxr-xr-x. 1 root root 69304 Dec 19 13:32 curl.so -rwxr-xr-x. 1 root root 2708336 Dec 19 13:32 fileinfo.so -rwxr-xr-x. 1 root root 46152 Dec 19 13:32 gmp.so -rwxr-xr-x. 1 root root 41576 Dec 19 13:32 json.so -rwxr-xr-x. 1 root root 49288 Dec 19 13:32 mssql.so -rwxr-xr-x. 1 root root 482372 Jan 6 14:15 oci8.so<<<<<======== -rwxr-xr-x. 1 root root 20256 Dec 19 13:32 pdo_dblib.so -rwxr-xr-x. 1 root root 124216 Jan 6 13:32 pdo_oci.so -rwxr-xr-x. 1 root root 101784 Dec 19 13:32 pdo.so -rwxr-xr-x. 1 root root 25984 Dec 19 13:32 pdo_sqlite.so -rwxr-xr-x. 1 root root 265584 Dec 19 13:32 phar.so -rwxr-xr-x. 1 root root 45744 Dec 19 13:32 sqlite3.so -rwxr-xr-x. 1 root root 41008 Dec 19 13:32 sybase_ct.so -rwxr-xr-x. 1 root root 94808 Dec 19 13:32 zip.so [root@localhost modules]# [root@localhost modules]# cd /etc/php.d [root@localhost php.d]# ll total 56 -rw-r--r--. 1 root root 49 Dec 19 13:32 curl.ini -rw-r--r--. 1 root root 57 Dec 19 13:32 fileinfo.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 gmp.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 json.ini -rw-r--r--. 1 root root 51 Dec 19 13:32 mssql.ini -rw-r--r--. 1 root root 18 Jan 6 14:16 oci8.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 pdo_dblib.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 pdo.ini -rw-r--r--. 1 root root 22 Jan 6 13:59 pdo_oci.ini -rw-r--r--. 1 root root 61 Dec 19 13:32 pdo_sqlite.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 phar.ini -rw-r--r--. 1 root root 55 Dec 19 13:32 sqlite3.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 sybase_ct.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 zip.ini [root@localhost php.d]# more oci8.ini extension=oci8.so but if i do this [root@localhost php.d]# rm -fr oci8.ini [root@localhost php.d]# ll total 52 -rw-r--r--. 1 root root 49 Dec 19 13:32 curl.ini -rw-r--r--. 1 root root 57 Dec 19 13:32 fileinfo.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 gmp.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 json.ini -rw-r--r--. 1 root root 51 Dec 19 13:32 mssql.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 pdo_dblib.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 pdo.ini -rw-r--r--. 1 root root 22 Jan 6 13:59 pdo_oci.ini -rw-r--r--. 1 root root 61 Dec 19 13:32 pdo_sqlite.ini -rw-r--r--. 1 root root 49 Dec 19 13:32 phar.ini -rw-r--r--. 1 root root 55 Dec 19 13:32 sqlite3.ini -rw-r--r--. 1 root root 59 Dec 19 13:32 sybase_ct.ini -rw-r--r--. 1 root root 47 Dec 19 13:32 zip.ini [root@localhost php.d]# php -v PHP Warning: PHP Startup: PDO_OCI: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20100525 These options need to match in Unknown on line 0 PHP 5.4.36 (cli) (built: Dec 19 2014 06:28:27) Copyright © 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright © 1998-2014 Zend Technologies no errror on PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - /usr/lib64/php/modules/oci8.so: undefined symbol: php_checkuid in Unknown on line 0 [root@localhost php.d]# thanks in advance Edited by taliez, 06 January 2015 - 11:40 PM. Hi Team, I have a php page where I have taken the same userid and linked in the next page and also used show/hide function. I am able to see that the userid is linking but when i submit the data is not getting insert and also no error Please help below is the Tower.php file. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP2</title> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1005px; height:578px; z-index:1; left: 157px; top: 1px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 35px; top: 35px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:243px; height:106px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:824px; height:271px; z-index:2; left: 44px; top: 237px; } .style4 { font-size: xx-large; font-style: italic; font-weight: bold; color: #FF9933; } #Layer8 { position:absolute; width:800px; height:139px; z-index:2; left: 31px; top: 67px; } #Layer9 { position:absolute; width:610px; height:30px; z-index:2; left: 34px; top: 70px; } #Layer10 { position:absolute; width:611px; height:25px; z-index:2; left: 33px; top: 110px; } #Layer11 { position:absolute; width:614px; height:30px; z-index:2; left: 33px; top: 152px; } #Layer12 { position:absolute; width:615px; height:29px; z-index:2; left: 32px; top: 193px; } #Layer13 { position:absolute; width:187px; height:35px; z-index:2; left: 318px; top: 239px; } --> </style> </head> <body> <div id="Layer1"> <form id="form5" name="form5" method="link" action="Insert.php"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="65" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <div align="center"><span class="style4">SELECT THE TOWER BELOW </span> <div id="Layer13"> <input type="hidden" name="empid" value="<?php echo $_GET['id']; ?>" size="20"> <input type="hidden" name="date" value="<?php echo date("Y-m-d H:i:s"); ?>" > <input type="submit" name="B1" value="Start !" /> </div> <div id="Layer12"> <div align="left"> <input name="rad1" type="radio" value="RF" id="rad1" /> <label >RF</label> </div> </div> <div id="Layer11"> <div align="left"> <input name="rad1" type="radio" value="ISAP" id="rad1" /> <label >ISAP</label> </div> </div> <div id="Layer10"> <div align="left"> <input name="rad1" type="radio" value="GSD" id="rad1" checked="checked" /> <label >GSD</label> </div> </div> <div id="Layer9"> <div align="left"> <input name="rad1" type="radio" id="rad1" value="CSD" /> <label>CSD</label> </p> </div> </div> <br /> </div> </div> </form> </div> </body> </html> Below is the insert.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"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP DATA SUMBIT</title> <?php include ("count.php"); ?> <?php if(isset($_GET['action'])) { $action = $_GET['action']; if ($action = 'yes') { include ("Connection.php"); $PName = $_POST['rad11']; $Date = date("Y-m-d H:i:s"); $empidno = $_POST['idd']; $qsdate = $_POST['testinput']; $cb1 = $_POST['chkbox1']; $cb2 = $_POST['chkbox2']; $cb3 = $_POST['chkbox3']; $cb4 = $_POST['chkbox4']; $cb5 = $_POST['chkbox5']; $Com = $_POST['textfield2']; $dd1 = $_POST['textfield']; $dd2 = $_POST['select']; $dd3 = $_POST['select2']; $dd4 = $_POST['textfield4']; $dd5 = $_POST['textfield3']; $dd6 = $_POST['select3']; $sev = $_POST['radio1']; $olddate = $_POST['odate']; $pname = $_POST['radiobutton']; $query="INSERT INTO bhp ticketinformation (`userid`, `processname`, `begindate`, `dateposted`, `CALL`, `EMAIL`, `NEW`, `EXISTING`, `Piroty`, `MTICKET`, `Services`, `group1`, `group2`, `Icall`, `Tcreatedtime`, `comment`) VALUES ( '$empidno' , '$pname' , '$olddate' , '$Date' , '$cb1' , '$cb2' , '$cb3' , '$cb4' , '$sev' , '$dd1' , '$dd2' , '$dd3' , '$dd4' , '$dd5' , '$dd6' , '$Com')"; mysql_query($query); Header('location:tower.php?id=' . $empidno); } } ?> <head> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1023px; height:592px; z-index:1; left: 167px; top: 2px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 59px; top: 3px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:238px; height:69px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:979px; height:209px; z-index:2; left: 32px; top: 181px; } #Layer8 { position:absolute; width:194px; height:36px; z-index:1; left: 25px; top: 15px; } #Layer9 { position:absolute; width:178px; height:37px; z-index:2; left: 249px; top: 13px; } #Layer10 { position:absolute; width:193px; height:34px; z-index:3; left: 443px; top: 13px; } #Layer11 { position:absolute; width:204px; height:32px; z-index:4; left: 670px; top: 15px; } #Layer12 { position:absolute; width:195px; height:40px; z-index:5; left: 28px; top: 73px; } #Layer13 { position:absolute; width:182px; height:38px; z-index:6; left: 250px; top: 76px; } #Layer14 { position:absolute; width:197px; height:36px; z-index:7; left: 446px; top: 77px; } #Layer15 { position:absolute; width:214px; height:35px; z-index:8; left: 670px; top: 77px; } #Layer16 { position:absolute; width:315px; height:45px; z-index:9; left: 16px; top: 144px; } #Layer17 { position:absolute; width:343px; height:43px; z-index:10; left: 339px; top: 145px; } #Layer18 { position:absolute; width:258px; height:48px; z-index:11; left: 708px; top: 146px; } #Layer19 { position:absolute; width:321px; height:60px; z-index:3; left: 59px; top: 419px; } #Layer20 { position:absolute; width:197px; height:41px; z-index:1; left: 27px; top: 6px; } #Layer21 { position:absolute; width:193px; height:36px; z-index:2; left: 249px; top: 7px; } #Layer22 { position:absolute; width:207px; height:38px; z-index:3; left: 453px; top: 7px; } #Layer23 { position:absolute; width:237px; height:36px; z-index:4; left: 677px; top: 9px; } #Layer24 { position:absolute; width:245px; height:45px; z-index:5; left: 399px; top: 2px; } #Layer25 { position:absolute; width:99px; height:31px; z-index:6; left: 288px; top: 121px; } #Layer26 { position:absolute; width:87px; height:29px; z-index:7; left: 439px; top: 123px; } --> </style> <script language="JavaScript" > function showInfo() { var elem = document.getElementById('verify'); if(document.testform.select3.value == "verify" || document.testform.select3.value == "verify1" ) { elem.style.display="inline"; } else { elem.style.display="none"; } } </script> <script language="JavaScript"> function validator() { if(document.testform.Checkbox1.checked == false && document.testform.Checkbox2.checked == false && document.testform.Checkbox3.checked == false && document.testform.Checkbox4.checked == false) { alert ('You did not choose any of the checkboxes!'); return false; } if (document.testform.textfield.value =="") { alert("Enter Max Ticket No"); return false; } if (document.testform.select.value == "" || document.testform.select.value == "SELECT SERVICE DROP DOWN") { alert ('Select the SELECT SERVICE DROP DOWN'); return false; } if (document.testform.select2.value == "" || document.testform.select2.value == "SELECT RG GROUP") { alert ('SELECT RG GROUP'); return false; } if (document.testform.select3.value == "" || document.testform.select3.value == "SELECT GROUPS") { alert ('SELECT GROUPS'); return false; } if (document.testform.textfield2.value =="") { alert("Comments Feild is Empty.If there are no Comment then type NA(Not Applicable)"); return false; } if (document.testform.Checkbox1.checked == false) document.getElementById("chkbox1").value = ""; else document.getElementById("chkbox1").value = "EMAIL"; if (document.testform.Checkbox2.checked == false) document.getElementById("chkbox2").value = ""; else document.getElementById("chkbox2").value = "NEW"; if (document.testform.Checkbox3.checked == false) document.getElementById("chkbox3").value = ""; else document.getElementById("chkbox3").value = "EXISTING"; if (document.testform.Checkbox4.checked == false) document.getElementById("chkbox4").value = ""; else document.getElementById("chkbox4").value = "CALL"; alert('Record has been posted in the portal'); } </script> </head> <body> <div id="Layer1"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="67" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <form method="POST" action="Insert.php?action=yes&&id=<?php echo $_GET['empid']; ?>" name="testform" onSubmit="return validator();"> <div id="Layer8"> <input type="checkbox" id="Checkbox4" name="checkbox4" value="CALL" /> CALL</label> </div> <div id="Layer9"> <label> <input type="checkbox" id="Checkbox1" name="checkbox1" value="EMAIL" /> EMAIL</label> </div> <div id="Layer10"> <label> <input type="checkbox" id="Checkbox2" name="checkbox2" value="NEW" /> NEW</label> </div> <div id="Layer11"> <label> <input type="checkbox" id="Checkbox3" name="checkbox3" value="EXISTING" /> EXISTING</label> </div> <div id="Layer12"> <label> <input name="radio1" type="radio" id="radio1" value="P1" checked="checked" /> P1</label> </div> <div id="Layer13"> <label> <input name="radio1" type="radio" id="radio1" value="P2" /> P2</label> </div> <div id="Layer14"> <label> <input name="radio1" type="radio" id="radio1" value="P3" /> P3</label> </div> <div id="Layer15"> <label> <input name="radio1" type="radio" id="radio1" value="P4" /> P4</label> </div> <div id="Layer16"> <label>MAXIMUM TICKET <input type="text" name="textfield" /> </label> </div> <div id="Layer17"> <label>SERVICE DROP DOWN <select name="select" style="width: 162px; height: 23px"> <option>SELECT SERVICE DROP DOWN</option> <option>OTHER(FW)</option> <option>1 MESSAGE</option> <option>1 MOBILITY</option> <option>1 VOICE</option> <option>1 SAP</option> <option>1 PORTAL</option> <option>1 COLLAB</option> <option>1 GSAP</option> <option>1 SECURITY</option> <option>1 WAN</option> <option>S DOMAIN</option> <option>1 AUTH</option> <option>1 DOCM</option> <option>1 REMOTE</option> </select> </label> </div> <div id="Layer18"> <label>RG GROUP <select name="select2" style="width: 162px; height: 23px"> <option>SELECT RG GROUP</option> <option>I-AM-AU-AM-HWT</option> <option>I-EUS-IN-CSC-DSK-CSD</option> <option>I-EUS-IN-CSC-DSK-GSD</option> <option>I-EUS-GB-DCS-BHPVICFW</option> <option>I-ITS-AU-HW</option> <option>I-SRM-AU-IAM-LAMU</option> <option>I-ITS-AU-SW</option> <option>C-BHP-AU-CSC-LSD-NONBRG</option> <option>C-BHP-AU-ACN-AQM</option> </select> </label> </div> </div> <div id="Layer19"> <label>SELECT GROUPS <select name="select3" onchange="showInfo()" style="width: 162px; height: 23px"> <option value="none" >SELECT GROUPS</option> <option value="verify">TP</option> <option value="verify1">OA</option> <option>OC</option> <option>OTHERS</option> </select> </label> <div id="verify" style="display:none;"> <br/><br/> <label>INCOMING CALL/EMAIL TIME <input type="text" name="textfield4" /> </label> <br/><br/> <label>MAXIMO TICKET CREATED TIME <input type="text" name="textfield3" /> </label> </div> <div id="Layer24"> <label>COMMENTS <input type="text" name="textfield2" /> </label> </div> <div id="Layer26"> <input name="Reset" type="reset" id="Reset" value="Reset" /> </div> <div id="Layer25"> <input type="submit" name="Submit" value="Submit" /> <input type="hidden" name="chkbox1" id="chkbox1" /> <input type="hidden" name="chkbox2" id="chkbox2" /> <input type="hidden" name="chkbox3" id="chkbox3" /> <input type="hidden" name="chkbox4" id="chkbox4" /> <input type="hidden" name="chkbox5" id="chkbox5" /> <input type="hidden" name="rad11" id="rad11" value="<?php echo $_GET['rad1']; ?>" /> <input type="hidden" name="idd" id="idd" value="<?php echo $_GET['empid']; ?>" /> <input type="hidden" name="odate" id="odate" value="<?php echo $_GET['date']; ?>" /> </form> </div> </div> </div> </body> </html> THANKS IN ADVANCED Hello....I am using ajax,jquery with php to insert data in db.....but the script is not working. form.html: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> label{ display:block; } </style> <script type="text/javascript" src="jquery-1.5.min.js"> </script> <script type="text/javascript"> $(function() { $('#submit').click(function(){ $('#container').append('<img src="ajax-loader.gif" id="loading" alt="image" />'); var name=$('#name').val(); var email=$('#email').val(); var d=$('#d').val(); var m=$('#m').val(); var y=$('#y').val(); var add=$('#add').val(); var phone=$('#phone').val(); $.ajax({ url: 'process.php', type: 'POST', data: 'name=' + name + '&email=' + email + '&d=' + d + '&m=' + m + '&y=' + y + '&add=' + add + '&phone=' + phone, success: function(result){ $('#response').remove(); $('#container').append('<p id="response">' + result + '</p>'); $('#loading').fadeOut(500,function(){ $(this).remove(); }); } }); return false; }); }); </script> </head> <body> <h2>User Registeration</h2> <form action="process.php" method="POST"> <div id="container"> Name:<br> <input type="text" name="name" id="name" /><br> Email:<br> <input type="text" name="email" id="email" /><br> Date Of Birth:<br> <input type="text" id="d" name="d" size="2" /> <input type="text" id="m" name="m" size="2" /> <input type="text" id="y" name="y" size="4" /><br> Address:<br> <input type="text" id="add" name="add" /><br> Phone:<br> <input type="text" id="phone" name="phone" /><br> <input type="submit" name="submit" id="submit" value="GO!" /> </div> </form> </body> </html> process.php My db id named "jquery" and table is "tab" Code: [Select] <?php $conns=mysql_connect("localhost","root",""); if(!$conns) echo "error in connection"; mysql_select_db("jquery", $conns); $name=$_POST['name']; $email=$_POST['email']; $m=$_POST['m']; $d=$_POST['d']; $y=$_POST['y']; $add=$_POST['add']; $phone=$_POST['phone']; echo $name,"<br>"; echo $email,"<br>"; echo $m, "<br>"; echo $d,"<br>"; echo $y,"<br>"; echo $add, "<br>"; echo $phone,"<br>"; $query="INSERT INTO tab (name,email,d,m,y,add,phone) VALUES ('$name',$email','$d','$m','$y','$add','$phone')"; if(!mysql_query($query,$conns)) echo "Error"; else echo "DATA inserted"; ?> The output shown is: pulkit pulkit@gmail.com 1 26 1991 lucknow 987576787 Error For some values i entered. Hello everyone, I am trying to submit a comment in a comment box and send it to the DB but is not happening. The connection is good as I am logging in and all but no data is sent to the DB when I post the comment. It doesn't show in my comment section either.
Form <!--comment section--> <?php if(isset($_SESSION['id'])) { echo "<form method='POST' action='" . setComments($conn) . "'> <input type='hidden' name='uidUsers' value='".$_SESSION['id']."'> <input type='hidden' name='posted' value='" . date('Y-m-d H:i:s') . "'> Comments: <textarea rows = '5' cols = '15' name='body'></textarea><br><br> <button name='commentSubmit' type='submit'>Comment</button> </form>"; }else { echo "Log in to comment!"; } getComments($conn);
Function to set and get comments function setComments($conn) { if (isset($_POST['commentSubmit'])){ $user_id = $_POST['uidUsers']; $body = $_POST['body']; $posted = $_POST['posted']; $sql = "INSERT INTO comments (uidUsers, posted, body) VALUES ('$user_id', '$posted', '$body')"; $result = mysqli_query($conn, $sql); } } function getComments($conn) { $sql = "SELECT * FROM comments"; $result = mysqli_query($conn, $sql); while ($row = $result->fetch_assoc()){ $id = $row['uidUsers']; $sql2 ="SELECT * FROM users WHERE uidUsers='$id'"; $result2 = mysqli_query($conn, $sql2); if($row2 = $result2->fetch_assoc()){ echo "<div class='comment-box'><p>"; echo $row2['uidUsers'] . "<br>"; echo $row['posted'] . "<br>"; echo nl2br($row['body']); echo "</p></div>"; } } }
I have some php code on view invoice and it's getting all the data I need to from three database tables but for some reason it's not getting the data for one specific column and unsure why I have done a echo sql and it is echoing the sql query ok and have ran the sql query in phpmyadmin and is displaying the column in phpmyadmin that is not displaying on the php page so am bit confused, below is the coding I have. I took out a lot of it and tried to keep to the relevant parts <?php $sql = "SELECT t1.id, t1.invoice_number, DATE_FORMAT(t1.invoice_date,'%d/%m/%Y') AS invoice_date, t1.user_id, t2.invoice_number, t2.service_name, t2.service_price, t3.user_id, t3.customer_name, t3.customer_phone, t3.customer_email, t2.service_name, t2.service_price, t1.invoice_total, t1.balance, t1.notes, DATE_FORMAT(t1.payment_date,'%d/%m/%Y') AS payment_date, t1.payment_method FROM invoices as t1 LEFT JOIN invoice_products as t2 ON t1.id = t2.invoice_id LEFT JOIN users as t3 ON t1.user_id = t3.user_id WHERE t1.user_id = '".$_SESSION['user_id']."' and t1.id = '".$_GET['id']."'"; $result = mysqli_query($connect, $sql); if(mysqli_num_rows($result) > 0) { if($row = mysqli_fetch_array($result)) { ?> Notes: <?php echo $row['notes'];?> <?php } } ?>
Hello all, I hope you are doing great.I am using phpmyadmin for the first time.So I created a table called guestbook with 4 attributes: id,name,email,message..Then I created a php file with the following code (saved in htdoc in Xampp folder)and html form which would take the data from the user and insert into the database which could later be retrieved.So far I have just written the insertion code which successfully creates the form but when I click on submit button it opens the same php file with the code and no insertion is made in the database..here is my code..please help me urgently..i have my project deadline very soon. php file called guest.php: <?php $user="root"; $password=""; $database="Guestbook"; $name=$_POST['name']; $email=$_POST['email']; $body=$_POST['body']; $connect("localhost",$user,$password); mysql($connect); @mysql_select_db($database)or die("unable to select db"); $query = mysql_query("INSERT INTO Guestbook(id,name,email,body) VALUES('','$name','$email','$body')"); if(!$query) { echo mysql_errno().':'.mysql_error(); } mysql_close(); ?> html file called new.html: <html> <head> <title>Guestbook</title> </head> <body> <form method="post" action="guest.php" > Name:<input type="text" name="name" size="30"/><br/> Email: <input type="text" name="email" size="30"/><br/> <p>Text:<br/> <textarea name="message" rows="15" cols="60"></textarea></p> <br/> <input type="submit" value="Submit"/> <input type="reset" value="Clear"/> </form> </body> </html> Hi folks, Complete No0b here when it comes to PHP and MySQL. I am in the middle of creating a PHP website. What I want to do is have the contents of a page in a MySQL table and have PHP gather the page content and display it on the page. Here is what I have in my home.tpl file: Code: [Select] <?php $query = "SELECT home, FROM $database_name"; $result = mysql_query($query); ?> And, in my index.php I simply call that home.tpl to display the data by using: Code: [Select] <?php include 'templates/default/home.tpl'; ?> Now, all I get is a blank page on index.php. Is there something else I should be doing? Remember, I am a complete No0b! Thanks folks. I am trying to create a code where the user enters the zip code and if found in the database, a location will be retrieved. I am getting two undefined variables as errors. I am still learning the POST and GET method and I fear that is where I am getting something mixed up. I have also attached an image of my DB. Thank you so much any input is greatly appreciated. Notice: Undefined variable: address in C:\xampp\htdocs\index.php on line 53 Notice: Undefined variable: zip in C:\xampp\htdocs\index.php on line 54
<?php include ('header.php'); include ('function.php'); ?> <div class="wrapper"> <div> <?php echo'<form method="POST" action"'.getLocations($conn).'"> <input type="text" name="zip" class="search" placeholder="Zip code"><br> <button type="submit" value="submit" id="submit">Submit</button> </form>'; getLocations($conn); ?> </div> </div> <div> <!--foreach($zip as $zip) : --> <?php echo $address['address']; echo $zip['zip']; ?> </div> function.php file code: <?php $dBServername = "localhost"; $dBUsername = "root"; $dBPassword = ""; $dBName = "addresses"; // Create connection $conn = mysqli_connect($dBServername, $dBUsername, $dBPassword, $dBName); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } function getLocations($conn) { if (isset($_POST['submit'])){ // Validate Zip code field if (!empty ($_POST['zip']) && is_numeric ($_POST['zip'])) { $zip = (int)$_POST['zip']; $query = "SELECT * FROM locations WHERE zip = '$zip'"; //get the results $result = mysqli_query($conn, $query); //fetch the data $zip = mysqli_fetch_all($result, MYSQLI_ASSOC); var_dump($zip); mysqli_free_result($result); //close connection mysqli_close($conn); } } }
Hey guys i am writing a code which will get data frm the user and then write a file in my server and well sadly i am really confused with the annoying errors and warnings i am getting please help here is my code <?php //This File Gets the data from the chat setup form and then writes the chat file or edits it //Get Data from the form $cname=$_POST['cname']; $nicklen=$_POST['nicklen']; $msglen=$_POST['msglen']; $pm=$_POST['pm']; $msgh=$_POST['msgh']; $aname=$_POST['aname']; $pass=$_POST['pass']; $cheight=$_POST['cheight']; $cwidth=$_POST['cwidth']; $prcadmin=$_POST['prcadmin']; $cas=$_POST['cas']; $frznick=$_POST['frznick']; $sm=$_POST['sm']; $id=$_COOKIE["id"]; //Check if the cookie id is empty if (!isset($id)) { header( 'Location: www.techbreeze.in/mychat/chat-add.html') ; } //Check if any field is empty and redirect to setup page if empty if ((isset($cname))&&(isset($nicklen))&&(isset($msglen))&&(isset($pm))&&(isset($msgh))&&(isset($aname))&&(isset($pass))&&(isset($cheight))&&(isset($cwidth))) { if ((is_numeric ($nicklen)) && (is_numeric ($msglen))&&(is_numeric($pm))&&(is_numeric($msgh))&&(is_numeric ($cheight))&&(is_numeric ($cwidth))) { //Start writting data into the file $str1=";"; $str2 = ".php"; $str4 = "\n"; $File = $id . $str2; $fh = fopen($File, 'w') or die("can't open file"); $stringData = "<?php\n"; fwrite($fh, $stringData); $strt1= "require_once /mychat/src/phpfreechat.class.php;\n"; $stringData = $strt1; fwrite($fh, $stringData); $strt1='$params["serverid"] ='; $stringData = $strt1 . $id . $str1 . $str4; fwrite($fh, $stringData); fclose($fh); $strt3 = "$params"; $stringData = $strt3; fwrite($fh, $stringData); fclose($fh); } else { echo "Only numeric Inputs allowed for the fields"; echo "<br><br><br>"; echo "Enter the maximum length of nick"; echo "<br>"; echo "Maximum Lenth of message"; echo "<br>"; echo "Max number of Simultaneous PM"; echo "<br>"; echo "No. of msg to be stored in history"; echo "<br>"; echo "Height of the Chat Room"; echo "<br>"; echo "Width of Chat Room"; echo "<br><br><br>"; echo "Please Fill them up Carefully!"; echo "<meta HTTP-EQUIV='REFRESH' content='6; url= http://www.techbreeze.in/chat-setup.html'>"; } } else { echo "You Have one or more incomplete Field"; echo "<br>"; echo "Please Fill them up Carefully!"; echo "<meta HTTP-EQUIV='REFRESH' content='2; url= http://www.techbreeze.in/chat-setup.html'>"; } ?> ok now the error i am getting is Quote Warning: fclose(): 3 is not a valid stream resource in /home/techbr/domains/techbreeze.in/public_html/mychat/chatcreate.php on line 52 Any ideas as to what i should do and why i am getting this error. <?php $GLOBALS['title']="Admission-HMS"; $base_url="http://localhost/hms/"; require('./../../inc/sessionManager.php'); require('./../../inc/dbPlayer.php'); require('./../../inc/fileUploader.php'); require('./../../inc/handyCam.php'); $ses = new \sessionManager\sessionManager(); $ses->start(); if($ses->isExpired()) { header( 'Location:'.$base_url.'login.php'); } else { $name=$ses->Get("loginId"); } $msg=""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST["btnSave"])) { $db = new \dbPlayer\dbPlayer(); $msg = $db->open(); echo '<script type="text/javascript"> alert("'.$msg.'");</script>'; if ($msg = "true") { $userIds = $db->getAutoId("U"); $flup = new fileUploader\fileUploader(); $perPhoto = $flup->upload("/hms/files/photos/",$_FILES['perPhoto'], $userIds[1]); // var_dump($perPhoto); $handyCam=new \handyCam\handyCam(); if (strpos($perPhoto, 'Error:') === false) { $dateNow=date("Y-m-d"); $data = array( 'userId' => $userIds[1], 'userGroupId' => "UG004", 'name' => $_POST['name'], 'studentId' => $_POST['stdId'], 'cellNo' => $_POST['cellNo'], 'gender' => $_POST['gender'], 'dob' => $handyCam->parseAppDate($_POST['dob']), 'passportNo' => $_POST['passportNo'], 'fatherName' => $_POST['fatherName'], 'fatherCellNo' => $_POST['fatherCellNo'], 'perPhoto' => $perPhoto, 'admitDate' => $dateNow, 'isActive' => 'Y' ); $result = $db->insertData("studentinfo",$data); if($result>=0) { $data = array( 'userId' => $userIds[1], 'userGroupId' => "UG004", 'name' => $_POST['name'], 'loginId' => $_POST['stdId'], 'verifyCode' => "vhms2115", 'expireDate' => "2115-01-4", 'isVerifed' => 'Y' ); $result=$db->insertData("users",$data); if($result>0) { $id =intval($userIds[0])+1; $query="UPDATE auto_id set number=".$id." where prefix='U';"; $result=$db->update($query); // $db->close(); echo '<script type="text/javascript"> alert("Admitted Successfully.");</script>'; } else { echo '<script type="text/javascript"> alert("' . $result . '");</script>'; } } elseif(strpos($result,'Duplicate') !== false) { echo '<script type="text/javascript"> alert("Student Already Exits!");</script>'; } else { echo '<script type="text/javascript"> alert("' . $result . '");</script>'; } } else { echo '<script type="text/javascript"> alert("' . $perPhoto . '");</script>'; } } else { echo '<script type="text/javascript"> alert("' . $msg . '");</script>'; } } Hi, I am a newbie to this forum and php as well. I have a script which inserts data and image file into mysql database. Now I want to display this image on web page but unable to do it. I tried a lot but couldn't find out any solution. I would appreciate your help. <?php $con = mysql_connect("localhost", "root", "xx"); if(!$con) { die('Could not connect:' .mysql_error()); } mysql_select_db("yyy",$con); $memberid = '$_POST[memberid]'; $fname = '$_POST[fname]'; $lname = '$_POST[lname]'; $gender= '$_POST[gender]'; $add1 = '$_POST[add1]'; $add2 = '$_POST[add2]'; $city = '$_POST[city]'; $state = '$_POST[state]'; $zip = '$_POST[zip]'; $country = '$_POST[country]'; $photo1 = '$_FILES[image][name]'; echo "$photo1"; //if ($memberid= $_GET['memberid']){ $query="select memberid,fname,lname,gender,add1,add2,city,state,zip,country,photo1 from vadhuvar_member where memberid =(select max(memberid)from vadhuvar_member)"; $result=mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $memberid = $row['memberid']; $fname = $row['fname']; $lname = $row['lname']; $gender = $row['gender']; $add1 = $row['add1']; $add2 = $row['add2']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $country = $row['country']; //$photo1=chunk_split(base64_encode($photo1)); $photo1 = $row['photo1']; //echo base64_encode($photo1); echo "Name:$fname $lname<br>"; //echo "Name:$_POST[fname]$_POST[lname]<br>"; echo "Gender:$gender<br>"; echo "Address:$add1 $add2<br>"; echo "$city $state $zip<br>"; echo "$country<br>"; //echo "<img src=".upload/$photo1 ." alt="" width="200" height="300" /><br />"; } //} ?> <!--img src="<?php echo '.upload/$_FILES[image][name]?memberid=$row[memberid]'?>"alt="" width="200" height="300"/-->; <?php echo "<img src=". upload/$row[photo1]" alt="" width="200" height="300">";?> <!--img src="<?php echo ".\upload\$photo1" ?>" alt="" width="200" height="300"/-->; <? set_magic_quotes_runtime(1); // turn back on ?> Thanks Smita i have a dropdown menu that displays the options i have in a database. i have this all working in mysqli as i didnt write this part on another website. but i am struggling to convert it back to mysql. the original code is: $query = "SELECT gallery_type_id, gallery_type_desc FROM gallery_type ORDER BY gallery_type_id"; /* run the query */ $result = $dbLink->query($query); /* load the query's results into an array */ $i=1; while($row=$result->fetch_assoc()){ $galleryTypes[$i] = $row; $i++; } $num_results = $result->num_rows; <select name="gallery_type" id="gallery_type"> <option>Please Select an Album <?php for($i = 1; $i < $num_results+1; $i++) { echo "<option value=\"" . $galleryTypes[$i]['gallery_type_id'] . "\">"; echo $galleryTypes[$i]['gallery_type_desc']; echo "</option>\n"; } ?> the code i have got so far: $query1 = "SELECT id, question FROM securtiyq ORDER BY id"; /* run the query */ $result= mysql_query($query1); $row = mysql_fetch_array($result); /* load the query's results into an array */ $i=1; while ($row = mysql_fetch_assoc($result)) { $galleryTypes[$i] = $row; $i++; } $num_results = mysql_num_rows($result); <select name="gallery_type" id="gallery_type"> <option>Please Select A Security Question <?php for($i = 1; $i < $num_results+1; $i++) { echo "<option value=\"" . $galleryTypes[$i]['id'] . "\">"; echo $galleryTypes[$i]['question']; echo "</option>\n"; } ?> </option> </select> the only problem is nothing from the database is displayed in the dropdown box. could someone point out where im going wrong thanks in advance Hello. If someone can help me, i'll be grateful So i have a foreach and an $output .= function that fills some infos in a table. Inside it i have a div for each line that when hovering your mouse should get some data .. Here i have a big problem, because for each line it should get some data and i don't know how to do it ... i'll post here some of my code for better understanding. Quote //some java here <?php require "class.php"; $server_list = query_group(); $misc = server_misc($server); foreach ($server_list as $server) { $misc = server_misc($server); $server = server_html($server); $idi = "{$server['o']['id']}"; $harta = "<a onmouseover=\"ShowContent('harta'); return true;\" onmouseout=\"HideContent('harta'); return true;\" href='".link($server['o']['id'])."' target=\"_self\">{$server['s']['map']}</a> <div style=\"position:absolute;\" id=\"harta\" class=\"FAQ\">file_get_contents('http://mysite/player.php?d={$idi}')</div> "; $output .= " <table> ........... some code..... <td> {$harta} </td> ....... so basicly when i hover my mouse over each row it should get data from the file for that id... The problem is that only one page can be loaded with file_get_contents. I read over the internet that some ajax functions can do it but i really don't know how. Please help me, i've been looking for 3 days already without any luck This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305885.0 Hello there, I have a script which uses the LOAD DATA LOCAL INFILE command see below: <?php //connect to your database mysql_connect("localhost", "xxx", "xxx"); //(host, username, password) //specify database mysql_select_db("xxx") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "LOAD DATA INFILE '/public_html/admin/files/test-jp-stock.csv' INTO TABLE 'jpaero_stocksearch' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; if(mysql_query($query)){ echo ">> New Stock Data has now been uploaded. Database is now live and searchable.";} else{ echo "Upload failed. Please contact support.";} ?> Initially I uploaded the csv file through phpmyadmin and everything worked fine - so I then used the SQL generated inside my script, changing the location to where the file actually is - however now nothing happens at all. Any ideas on whats gone wrong, gratefully received! Thanks, Hi guys, Should be a simple 1. If i have the following at the top of the page: $page_views = $row['page_views'] + 1; mysql_query("UPDATE table SET page_views='$page_views'"); and then the following at the bottom of the page: echo $row['page_views']; Should I see the page views as 1 the first time the page is visited, 2 the second time the page is visited, and so on......? At the moment im seeing 0 on the first page visit, 1 on the second page visit, 2 on the third..... I had this problem before on another page i was working, and i simply solved it by displaying the mysql query above the echo similar to the code above. However now it does not seem to be working. Am i missing something really simple? lol Thanks Hi all, Is it possible in php to read data from file as binary and operate on it with bitwise operators and save result as binary. Thanks (last question for this project...!) This code loads and image from a URL stored in a database. Some of the results pages wont have an image stored in them and I don't want it to load the "image not found" icon. Therefore I have uploaded a transparent .gif file and would like that to load if no result was found in the database. I am using IF and ELSE but this doesn't seem to work correctly - Can anyone advise on what I am doing wrong please. Thanks <?php $van_query = "SELECT Image_Van FROM products WHERE Car_Make= '$strMake' AND Car_Model = '$strModel'"; // the result of the query $van_result = mysql_query($van_query) or die("Invalid query: " .mysql_error()); $pic = mysql_fetch_array($van_result); // show the image if ($van_query !== "") echo "<img src='images/product_images/".$pic['Image_Van']."'/>"; else echo "<img src=\"images/transparent.gif/>"; ?> |