PHP - Newbie Php Problem
Similar TutorialsI've been searching for a couple of days on google using keywords, trying to figure out why this form sends blank emails. I've found several different ways to write something like this, including what's below, but for the life of me I haven't figured it out. Can anyone help a brother out? <?php $email = $_REQUEST['email']; $message = $_REQUEST['date']; $message .= $_REQUEST['location']; $message .= $_REQUEST['quantitymodel']; mail( "name@email.com", "Email Contact Form", $message, "From: $email" ); header( "Location: thankyou.html" ); ?> Hi, Im pretty new to php but im have trouble understanding why my script is doing this. Forgive me for silly mistakes! Im creating a login/register website and once the person has logged in they get a message saying "Successful login, welcome username!" The php checks against a database of users in an if statement to check if the password is correct and then prints out the message. But at the end of the message the echo is printing out a 1. I get that because the echo is in an if statement its return true or 1 but I cant get it to not print out the 1. code snippet is - if ($username==$dbusername&&$password==$dbpassword) { echo "Successful login, welcome!"; } Hope that makes sense. Thanks for the help. Neil HI there, i'm using a flash and php form. The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain. Could somebody tell me what i'm doing wrong? <?php $sendTo = "myemail@gmail.com"; $subject = "An enquiry"; $headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $headers .= "Return-path: " . $_POST["email"]; $message = "telephone: ".$strtelephone."\r\n"; $message .= "message: ".$strmessage."\r\n"; mail($sendTo, $subject, $message, $headers); ?> thank you I am learning PHP/MySQL and am modifying a tutorial to make a contact database. All I want is to be able to make a web page for each contact(record) and display one record on each webpage. I want to use the URL featu "http://www.mysite.com/script.php?=item1" type of thing Can any help me as I can't get it to work. I get no errors - it just doesnt display the info. I'm sure I cant be far off as I've only modified a working script ever so slightly. Code: [Select] mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); ?> <? $query="SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Phone</font></th> <th><font face="Arial, Helvetica, sans-serif">Mobile</font></th> <th><font face="Arial, Helvetica, sans-serif">Fax</font></th> <th><font face="Arial, Helvetica, sans-serif">E-mail</font></th> <th><font face="Arial, Helvetica, sans-serif">Website</font></th> </tr> <? $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo "$first $last"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$phone"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$mobile"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo "$fax"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo "$email"; ?>">E-mail</a></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="<? echo "$web"; ?>">Website</a></font></td> </tr> <? ++$i; } echo "</table>"; ?> I got this code
<?php // Check if session is not registered, redirect back to main page. // Put this code in first line of web page. session_start(); if (!isset($_COOKIE["user"])) { header("location:login.php"); } include 'connection.php'; ?> <html> <head> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="HandheldFriendly" content="true"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>EBS Service Skjema</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <?php include 'menu.php'; echo "<div class=\"bluebox\">"; if (isset($_GET['sted'])) { require_once('graph/jpgraph.php'); require_once('graph/jpgraph_line.php'); include 'connection.php'; // data $sql = mysqli_query($con, "SELECT * FROM diesel WHERE sted = '".$_GET['sted']."' GROUP BY WEEK(dato)"); $ydata = array(); $ydate = array(); while($row = mysqli_fetch_array($sql)) { $ydata[]=$row['krl']; $ydate[]=$row['dato']; } // Create the graph. These two calls are always required $graph = new Graph(600,250); $graph->SetScale('textlin'); $graph->title->Set('Pris Historikk'); $graph->xaxis->title->Set("Dato"); $graph->yaxis->title->Set("Pris"); $graph->xaxis->SetTickLabels($ydate); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot->SetColor('blue'); //$lineplot->SetFillColor('orange@0.5'); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); } else { echo "Du får ikke tilgang på denne måten."; } echo "</div>"; ?> </body> </html>but I get headers allready sent. I was earlier told to learn and code or make my apps different, but I'm totaly stuck cause I need to make a page with those stats. Not sure how I can make all my code be processed first then put into the html area. Is a function the way to go here ? Thanks for reading and hope someone can enlighten me Hello I've registered here last March and I'm just lurking around reading threads about php. Yesterday I've started to self studied php and today I've test some basic codes and I'm having difficulties on creating a table rows and columns. Here's my code. Code: [Select] <?php echo "<table width=\"100\" border=\"1\">"; $text = 'php'; $mac_var = 1; $mac_plus = 4; while ($mac_var < $mac_plus) { echo "<tr>"; { while ($mac_var < $mac_plus) { echo "<td>". $text . "</td>"; $mac_var++; } } echo "</tr>"; $mac_var++; } echo "</table>"; ?> what I want is, it should have 3 columns and 3 rows. But I'm getting only 3 columns and 1 row only. I wonder what is the problem? Sorry for my ignorance as I'm on the 1st basic phase of using php codes. TIA! hello, I'm a beginner when it comes to PHP: I'm working on a log in system but i keep on getting the same errors which makes my system unreliable. this is the function I'm trying to use: if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } --> I'm using a postgresql database this is the warning I keep on getting: Code: [Select] Warning: pg_numrows(): supplied argument is not a valid PostgreSQL result resource in /var/ftpdirs/512544/PHP/login/adduser.php on line 13 I have the same problem when I try to look if an username is taken or not... when people try to register this is my adduser.php file: <?php session_start(); include "connectie_db.php"; $User_name = $_POST['user_name'] ; $User_pass = $_POST['user_pass'] ; $User_pass2 = $_POST['user_pass2'] ; $checkUsername= "SELECT user_name from tovanu.users where user_name = '$User_name';"; $q = $db->exec($checkUsername); if(MDB2::isError($q)){ echo "code: ".$q->getUserInfo(); exit(); } if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } If(strlen($User_name > 32)){ echo "<p>The username is too long</p>"; include "signup.php"; exit; } if($User_pass != $User_pass2){ echo "<p>Both passwords must be the same</p>"; include "signup.php"; exit; } $password = md5($User_pass); $add = "INSERT INTO tovanu.users (user_name,user_pass,user_email,user_date,user_level,naam,adres,plaats,postcode) VALUES ('$User_name','$password','email',current_date,1,'jef','jonhstraat','maaseik','3687')"; $execute = $db->exec($add) ; if(MDB2::isError($execute)){ echo "code: ".$q->getUserInfo(); exit(); } $_SESSION['user'] = $username; include "index.php"; ?> any help would be appreciated!!!!!!!!!!! I have the following xml file... <property id="21179035" propertyid="111290" system="A" firmid="11548" branchid="1" database="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://webservices.vebra.com/export/xsd/v1/exportapi.xsd"> <reference> <agents>11290</agents> </reference> <address> <name>16</name> <street>Bardsey Close</street> <locality>Wootton Bassett</locality> <town>Swindon</town> <county>Wilts</county> <postcode>SN4 8NA</postcode> <custom_location>West of Swindon</custom_location> <display>Wootton Bassett, Swindon</display> </address> <price qualifier="" currency="GBP">107750</price> <rm_qualifier>0</rm_qualifier> <available>01/01/1900</available> <uploaded>04/08/2010</uploaded> <longitude>-1.886723</longitude> <latitude>51.54373</latitude> <easting>407855</easting> <northing>182820</northing> <web_status>1</web_status> <custom_status /> <comm_rent /> <premium /> <service_charge /> <rateable_value /> <type>Maisonette</type> <type /> <furnished>3</furnished> <rm_type>0</rm_type> <let_bond>0</let_bond> <rm_let_type_id>0</rm_let_type_id> <bedrooms>2</bedrooms> <receptions>0</receptions> <bathrooms>1</bathrooms> <userfield1 /> <userfield2>0</userfield2> <area measure="metric" unit="sqm"> <min>0</min> <max>0</max> </area> <area measure="imperial" unit="sqft"> <min>0</min> <max>0</max> </area> <description>Primary are pleased to offer this two bedroom first floor maisonette in Wootton Bassett. The accommodation comprises of private entrance hall, lounge, kitchen, two bedrooms and bathroom. The property also benefits from uPVC double glazing, central heating and two allocated parking spaces. No onward chain. </description> <hip> <energy_performance> <energy_efficiency> <current>67</current> <potential>77</potential> </energy_efficiency> <environmental_impact> <current>67</current> <potential>80</potential> </environmental_impact> </energy_performance> </hip> <paragraphs> <paragraph id="1" type="0"> <name>DESCRIPTION</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Primary are pleased to offer this two bedroom first floor maisonette in Wootton Bassett. The accommodation comprises of private entrance hall, lounge, kitchen, two bedrooms and bathroom. The property also benefits from uPVC double glazing, central heating and two allocated parking spaces. No onward chain. </text> </paragraph> <paragraph id="2" type="0"> <name>PRIVATE ENTRANCE PORCH</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Storage cupboard.</text> </paragraph> <paragraph id="3" type="0"> <name>PRIVATE ENTRANCE HALL</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Stairs leading to first floor. Radiator.</text> </paragraph> <paragraph id="4" type="0"> <name>FIRST FLOOR</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Landing: Loft access (part boarded), built in storage cupboard with hanging rail, airing cupboard. Doors leading to lounge, bathroom and both bedrooms.</text> </paragraph> <paragraph id="5" type="0"> <name>LIVING ROOM</name> <file ref="1" /> <dimensions> <metric /> <imperial /> <mixed>5.05m(16'7'') x 3.43m(11'3'')</mixed> </dimensions> <text>uPVC double glazed window to front elevation. TV point. Telephone point. Radiator. Door leading to:</text> </paragraph> <paragraph id="6" type="0"> <name>KITCHEN</name> <file ref="2" /> <dimensions> <metric /> <imperial /> <mixed>2.57m(8'5'') x 2.54m(8'4'')</mixed> </dimensions> <text>uPVC double glzed window to rear elevation. Wall and base units with rolled edge work surfaces over. Wall mounted central heating boiler and thermostat. Space for fridge freezer, oven and washer drier. Tiled splashbacks.</text> </paragraph> <paragraph id="7" type="0"> <name>BEDROOM ONE</name> <file ref="3" /> <dimensions> <metric /> <imperial /> <mixed>3.76m(12'4'') x 3.05m(10'0'')</mixed> </dimensions> <text>uPVC double glazed window to front elevation. Built in double wardrobe. Telephone extension. Radiator.</text> </paragraph> <paragraph id="8" type="0"> <name>BEDROOM TWO</name> <file /> <dimensions> <metric /> <imperial /> <mixed>3.71m(12'2'') x 2.26m(7'5'')</mixed> </dimensions> <text>uPVC double glazed window to rear elevation. Radiator.</text> </paragraph> <paragraph id="9" type="0"> <name>BATHROOM</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Obscure uPVC double glazed window to rear elevation. White suite comprising of panel bath with shower over, pedestal hand wash basin and low level WC. Radiator.</text> </paragraph> <paragraph id="10" type="0"> <name>VIEWING</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Strictly via our Swindon office telephone (01793) 641641, out of office hours Dawn Graham 07887763163.</text> </paragraph> <paragraph id="11" type="0"> <name>MORTGAGES</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>If you would like independent mortgage advice please call Primary Mortgage Centre on (01793) 616617. Home visits available.</text> </paragraph> <paragraph id="12" type="0"> <name>MONEY LAUNDERING</name> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>Intending purchasers will be asked to produce identification documentation at a later stage and we would ask for your co-operation in order that there will be no delay in agreeing the sale.</text> </paragraph> <paragraph id="13" type="2"> <name /> <file /> <dimensions> <metric /> <imperial /> <mixed /> </dimensions> <text>This footer paragraph is an example only and should not be relied upon as complying with current legislation. These particulars, whilst believed to be accurate are set out as a general outline only for guidance and do not constitute any part of an offer or contract. Intending purchasers should not rely on them as statements of representation of fact, but must satisfy themselves by inspection or otherwise as to their accuracy. No person in this firms employment has the authority to make or give any representation or warranty in respect of the property.<br/></text> </paragraph> </paragraphs> <bullets> <bullet id="1">First Floor Maisonette</bullet> <bullet id="2">Two Bedrooms</bullet> <bullet id="3">Lounge</bullet> <bullet id="4">Kitchen</bullet> <bullet id="5">Private Entrance</bullet> <bullet id="6">Allocated Parking</bullet> <bullet id="7">Good Location</bullet> <bullet id="8">No Onward Chain</bullet> </bullets> <files> <file id="0" type="0"> <name /> <url>http://images.vebra.com/images/1548/001/type1/bardse~1.jpg</url> <updated>30/08/2011 17:03:00</updated> </file> <file id="1" type="0"> <name>LIVING ROOM</name> <url>http://images.vebra.com/images/1548/001/type1/bardse~2.jpg</url> <updated>30/08/2011 17:03:00</updated> </file> <file id="2" type="0"> <name>KITCHEN</name> <url>http://images.vebra.com/images/1548/001/type1/bardse~3.jpg</url> <updated>30/08/2011 17:03:00</updated> </file> <file id="3" type="0"> <name>BEDROOM ONE</name> <url>http://images.vebra.com/images/1548/001/type1/bardse~4.jpg</url> <updated>30/08/2011 17:03:00</updated> </file> <file id="4" type="9"> <name>Energy efficiency chart</name> <url>http://images.vebra.com/home/hip/EE_0275_067_077.png</url> </file> <file id="5" type="9"> <name>Environmental impact chart</name> <url>http://images.vebra.com/home/hip/EI_0275_067_080.png</url> </file> </files> </property> I have the following code... # address - basic info if(is_object($xml->address)) { foreach($xml->address as $address) { //print_r($property); $name = $address->name; $street = $address->street; $locality = $address->locality; $town = $address->town; $county = $address->county; $postcode = $address->postcode; $custom_location = $address->custom_location; $display = $address->display; $insertS = "INSERT INTO $tablec (pal, afield, bfield, cfield, dfield, efield, ffield, hfield, ifield, jfield) VALUES (110, '$bD->afield', '$name', '$street', '$locality', '$town', '$county', '$postcode', '$custom_location', '$display')"; $insertQ = mysql_query($insertS); $iid = mysql_insert_id(); } } # property - basic info if(is_object($xml)) { foreach($xml as $property) { //print_r($property); $long = $property->longitude; $lat = $property->latitude; $type = $property->type; $furnished = $property->furnished; $bedrooms = $property->bedrooms; $bathrooms = $property->bathrooms; $description = $property->description; $updateS = "UPDATE $tablec SET kfield = '$long', lfield = '$lat', mfield = '$type', nfield = '$furnished', ofield = '$bedrooms', pfield = '$bathrooms', atext = '$description' WHERE pal = 110 AND id = $iid"; $updateQ = mysql_query($updateS); print "<p>$updateS</p>"; } } The first bit is working fine (# address - basic info) and I am able to get the information out, however the longitude and latitude bit I'm struggling with (# property - basic info) Any help would be much appreciated. I have got some xml which I have ran $xml = simplexml_load_string($result); Now I need to be able to access the values in a for loop, I've done this before, but it escapes me. The XML code is as follows... <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?> <branches xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://webservices.vebra.com/export/xsd/v1/exportapi.xsd"> <branch> <name>Swindon</name> <firmid>11548</firmid> <branchid>1</branchid> <url>http://webservices.vebra.com/export/primaryexechomesAPI/v1/branch/3762</url> </branch> <branch> <name>Swindon</name> <firmid>17548</firmid> <branchid>11</branchid> <url>http://webservices.vebra.com/export/primaryexechomesAPI/v1/branch/10061</url> </branch> </branches> My code for trying to get the values when in a for loop is... # format xml and insert the different branches into the db $xml = simplexml_load_string($result); # loop through the number of branches //$branches = count($xml); for($b = 0; $b < count($xml); $b++) { //$name = $xml->name; //$name = $xml->['name']; //$name = $xml['name']; //$name = $xml['branch']; //$name = $xml->['branch']['name']; //$name = $xml[$b]->['branch']['name']; $name = $xml->['branch']['name']; print "<h1>Name</h1>"; } As you can see I've tried to get the value out, just cant seem to do it. Any help will be much appreciated! okay so my problem is..i need to put the logo inside this fancybox..when u click page 1..it will link to page 2(fancybox). Inside the fancybox i want to put the logo..i attached a sample..just like on page 3.. this is code for page 1 and page2(fancybox page) Code: [Select] <select name="month" onchange="this.form.submit();"> <option <?php if ($_POST['month'] == 'All') print 'selected '; ?> value="All">All</option> <option <?php if ($_POST['month'] == 'January') print 'selected '; ?> value="January">January</option> <option <?php if ($_POST['month'] == 'February') print 'selected '; ?> value="February">February</option> <option <?php if ($_POST['month'] == 'March') print 'selected '; ?> value="March">March</option> <option <?php if ($_POST['month'] == 'April') print 'selected '; ?> value="April">April</option> <option <?php if ($_POST['month'] == 'May') print 'selected '; ?> value="May">May</option> <option <?php if ($_POST['month'] == 'June') print 'selected '; ?> value="June">June</option> <option <?php if ($_POST['month'] == 'July') print 'selected '; ?> value="July">July</option> <option <?php if ($_POST['month'] == 'August') print 'selected '; ?> value="August">August</option> <option <?php if ($_POST['month'] == 'September') print 'selected '; ?> value="September">September</option> <option <?php if ($_POST['month'] == 'October') print 'selected '; ?> value="October">October</option> <option <?php if ($_POST['month'] == 'November') print 'selected '; ?> value="November">November</option> <option <?php if ($_POST['month'] == 'December') print 'selected '; ?> value="December">December</option> </select> </div> <br> <? $monthname=$_POST['month']; if (isset($_GET['np'])){ $num_pages=$_GET['np']; } else { if($searchtype == 'yes') if ($monthname=="All" || $monthname=="") { $query = "SELECT count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom desc"; }else { $query = "SELECT count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom desc"; } else if ($monthname=="All" || $monthname=="") { $query = "Select count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom desc"; }else { $query = "Select count(*) FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom desc"; } $result=mysql_query($query); $row=mysql_fetch_array($result, MYSQL_NUM); $num_records=$row[0]; if ($num_records > $displayhome){ $num_pages=ceil($num_records/$displayhome); } else { $num_pages=1; } } if (isset($_GET['s'])){ $start=$_GET['s']; } else { $start=0; } if ($monthname=="All" || $monthname=="") { $query = "SELECT master_event.*,master_type.type_name, DATE_FORMAT(event_datefrom, '%d %b %y') as datefrom, DATE_FORMAT(event_dateto, '%d %b %y') as dateto, event_venue, (event_name) as eventname FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 order by event_datefrom asc LIMIT $start, $displayhome"; }else { $query = "SELECT master_event.*,master_type.type_name, DATE_FORMAT(event_datefrom, '%d %b %y') as datefrom, DATE_FORMAT(event_dateto, '%d %b %y') as dateto, event_venue, (event_name) as eventname FROM master_event LEFT JOIN master_type ON master_type.type_id = master_event.type_id where isupcomingevent = 1 AND MONTHNAME(event_datefrom) = '$monthname' order by event_datefrom asc LIMIT $start, $displayhome"; } $result = mysql_query($query); $bg='#e5e5e5'; while($row = mysql_fetch_array($result)){ $eventid = $row['event_id']; $eventname = str_replace("", "", $row['eventname']); $eventdatefrom = $row['datefrom']; $eventdateto = $row['dateto']; $event_venue = $row['event_venue']; $event_desc = $row['event_desc']; $speakerlist = $row['speakerlist']; $showline1 = ""; $showpros =""; $showline2 = ""; $showreg =""; $showline3 = ""; $showps =""; $showline4 = ""; $showtestimonial =""; $showline5 = ""; $showsp =""; $showline6 = ""; $showsl =""; if ($eventdatefrom ==$eventdateto) { $eventdate = $eventdatefrom; } else { $eventdate = $eventdatefrom . " - " . $eventdateto; } $querypros="select count(*) as proscount from master_prospectus where event_id ='$eventid' "; $resultpros = mysql_query($querypros); while($rowpros = mysql_fetch_array($resultpros)){ $proscount = $rowpros['proscount']; if ($proscount > 0) { $showline1 = "|"; $showpros ="Request Brochure"; } } $queryreg="select (CASE WHEN event_dateto >= NOW() THEN 'valid' ELSE 'invalid' END) AS validreg from master_event where event_id ='$eventid' "; $resultreg = mysql_query($queryreg); while($rowreg = mysql_fetch_array($resultreg)){ $validreg = $rowreg['validreg']; if ($validreg == "valid") { $showline2 = "|"; $showreg ="Online Registration"; } } $queryps="select count(*) as pscount from master_psevent where event_id ='$eventid' "; $resultps = mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $pscount = $rowps['pscount']; if ($pscount > 0) { $showline3 = "|"; $showps ="Partner & Sponsor"; } } $querytesm="select count(*) as tesmcount from master_testimonial where event_id ='$eventid' "; $resulttesm = mysql_query($querytesm); while($rowtesm = mysql_fetch_array($resulttesm)){ $tesmcount = $rowtesm['tesmcount']; if ($tesmcount > 0) { $showline4 = "|"; $showtestimonial ="Testimonial"; } } $querysp="select count(*) as spcount from master_speakernote where event_id ='$eventid' "; $resultsp = mysql_query($querysp); while($rowsp = mysql_fetch_array($resultsp)){ $spcount = $rowsp['spcount']; if ($spcount > 0) { $showline5 = "|"; $showsp ="Speaker Notes"; } } if ($speakerlist <> '') { $showline6 = "|"; $showsl ="Speaker List"; } echo "<tr><p style=\"font-size:small;\"> <td width='' ><img src='images/search.png' alt='tooltips' ></img> <a href='index.php?view=event&content=tips&ttid=$eventid' title ='$eventname' class=\"fancybox fancybox.iframe\" style=\"color:#104E8B;text-decoration: none; \" ><strong><font size='2' face='Segoe UI' >$eventname</font></strong></a><br> <font color='#000000' size='2' face='arial' >Date : $eventdate <br> Venue : $event_venue<br></font> <table style=\"text-align: left; width: 400px; height: 92px;\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\"> <tbody> <tr> <td></td> <td style=\"text-align: justify; color: #000000;\"> <font color='#000000' size='2' face='arial' > $event_desc</font></td> <td></td> </tr> </tbody> </table> <font color='#919191' size='1' face='arial' ><b> <a href='index.php?view=prospectus®rq=$eventid' title ='Request Brochure...' >$showpros</a> <b>$showline1</b> <a href='index.php?view=registration®rq=$eventid' title ='Online Registration...' > $showreg </a> <b>$showline2</b> <a href='index.php?view=event&content=psevent&ttid=$eventid' title ='Sponsor & Partner...' class='fancybox fancybox.iframe' >$showps</a> <b>$showline3</b> <a href='index.php?view=event&content=tesm&ttid=$eventid' title ='Testimonial...' class='fancybox fancybox.iframe' >$showtestimonial</a> <b>$showline4</b> <a href='index.php?view=spl&splid=$eventid' > $showsp</a><b>$showline5</b> <a href='index.php?view=event&content=speaker&ttid=$eventid' title ='$eventname' class='fancybox fancybox.iframe' > $showsl</a></font><br><br></td> </p></tr></b></font> "; } if ($eventid=="") { echo "No Records Found."; } echo "<td><p style=\"font-size:1;\">"; echo "<br>"; if ($num_pages > 1) { $current_page = ($start/$displayhome) + 1; if ($current_page != 1) { echo '<a href="index.php?view=home&content=list&s=' . ($start - $displayhome) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">Previous</a> ';} for ($i = 1; $i <= $num_pages; $i++) { if ($i != $current_page) { echo '<a href="index.php?view=home&content=list&s=' . (($displayhome * ($i - 1))) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">' . $i . '</a> '; } else { echo '<font face="arial" size="2">'; echo $i . '</font> ';} } if ($current_page != $num_pages) { echo '<a href="index.php?view=home&content=list&s=' . ($start + $displayhome) . '&np=' . $num_pages . '#a" class="style1" style="color:#4F94CD;text-decoration: none;">Next</a>';} } echo "</p></td>"; ?> </tr> </div> </form> i want the logo like on page 3 to be on fancybox code for page 3(sample) Code: [Select] <? if(isset($_GET[ttid])) { $ttid = $_GET[ttid]; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query = "select master_event.* , (DATE_FORMAT(event_datefrom, '%d %M %Y')) as datefrom, (DATE_FORMAT(event_dateto, '%d %M %Y')) as dateto, ucase(event_name) as eventname from master_event where master_event.event_id = '$ttid '"; $result=mysql_query($query); while($row = mysql_fetch_array($result)){ $eventname = $row['eventname']; $eventdesc = $row['event_desc']; //$companydescription = $row['company_description']; $eventvenue = $row['event_venue']; $eventfee = $row['event_fee']; $datefrom = $row['datefrom']; $dateto = $row['dateto']; echo "<font color='#000000' face='arial' ><b> $eventname </b> </font> <br>"; echo "<font color='#000000' face='arial' ><i>Date</i> : $datefrom - $dateto <br>"; echo "<i>Venue</i> : $eventvenue <br>"; $querypstype = "SELECT DISTINCT master_pstype.pstype_id, pstype_desc FROM master_pstype INNER JOIN master_psevent ON master_psevent.pstype_id= master_pstype.pstype_id where master_psevent.event_id = '$ttid' ORDER BY pstype_order"; $resultpstype=mysql_query($querypstype); while($rowpstype = mysql_fetch_array($resultpstype)){ $pstypeid = $rowpstype['pstype_id']; $pstypedesc = $rowpstype['pstype_desc']; echo "<br><font color='#8B3A3A' size='1' face='georgia' ><b><i>$pstypedesc</i></b></font> <br>"; $queryps = "SELECT master_psevent.*, pstype_desc, company_name, company_link, company_description, logo_filename FROM master_psevent LEFT JOIN master_pstype ON master_psevent.pstype_id = master_pstype.pstype_id LEFT JOIN master_ps ON master_ps.ps_id = master_psevent.ps_id WHERE master_psevent.event_id = '$ttid' and master_pstype.pstype_id= '$pstypeid' ORDER BY pstype_desc,company_name "; $resultps=mysql_query($queryps); while($rowps = mysql_fetch_array($resultps)){ $companyname = $rowps['company_name']; $companyid = $rowps['ps_id']; $companylinkori = $rowps['company_link']; $companydescription = $rowps['company_description']; $logopath = $rowps['logo_filename']; $describelink = "index.php?view=describe&ttid=$ttid&pstypeid=$pstypeid&psid=$companyid"; if(!empty($companydescription)){ echo "<a href=\"$describelink\" target=\"_blank\"><img src=".$logo_dir."/".$logopath." width=\"15%\" border=\"0\"></a>"; } else { echo "<a href=\"$describelink\" target=\"_blank\"><img src=".$logo_dir."/".$logopath." width=\"15%\" border=\"0\"></a>"; } } } } ?> Ok, I am currently at Uni, with one of my units needing me to build a content management system. I have been learning PHP for about 2 months, so go easy on me. So I was developing happily, I was able to use the CMS to add a product, edit that product and delete it. I load it up today to carry on working on it, but find that adding a product no longer works. I investigate further and find that the HTML form on the "Add a product" section's processing page (createProduct.php) is not receiving the values from the form using the $_POST method, therefore the mysql query was containing empty values. I found this confusing as I had not changed any of the code. So i investigate further, creating a test php page, copying the $_POST method into here and echoing the variables. And.. it worked. Even more confused, I delved deeper and found that the culprit for the $_POST method not working was one of my includes. connection.php. Here is the connection.php include: Code: [Select] <?php //1. Create database connection $connection = mysql_connect("localhost", "root"); //No password on the DB yet as it is only local. if (!$connection) { die("Database connection failed: " . mysql_error()); } //2. Select database to use $db_select = mysql_select_db("cms",$connection); if (!$db_select) { die("Database selection failed: " . mysql_error()); } ?> And here is createProduct.php; Code: [Select] <?php require_once("../includes/connection.php");?> <?php require_once("../includes/functions.php");?> <?php ?> <?php //Populating the variables with values from the HTML form $Product_Name = mysql_prep($_POST['Product_Name']); $Price = mysql_prep($_POST['Price']); $Product_Information = mysql_prep($_POST['Product_Information']); $category_id = $_POST['category']; echo $Product_Name . "<br />"; echo $Price . "<br />"; echo $Product_Information . "<br />"; echo $category_id . "<br />"; ?> <?php //Creating and submitting the mysql query echo $category_id; $query = "INSERT INTO tblProducts( Product_Name, Price, Product_Information, category_id ) VALUES ( '{$Product_Name}', {$Price}, '{$Product_Information}', {$category_id} )"; echo $query; if (mysql_query($query, $connection)) { header("Location: createProduct.php"); exit; } //error handling else { echo "<p>Product creation failed.</p>"; echo "<p>" . mysql_error() . "</p>"; } ?> <?php mysql_close($connection); ?> So my question is.. why, when suddenly loading it up today after a few days absence would the database connection code be conflicting ONLY ON THIS PAGE. editing and deleting a product still work. I am truly stumped as this seems completley illogical and is probably something really obvious. Any help would be greatly appreciated. <?php $visitpage = "http://mywebsite.com/wp-content/uploads/test.jpg"; ?> <div style="text-align: center;"><img src=<?php echo $visitpage; ?>/></div> do you know why the image is not appearing in the coe above? why my syntax of php and html is wrong? Hi guys - i have some code which echos an image from a directory based on the user who is logged in... Code: [Select] <?php //to display image from source $dir = "profpics"; $sql = "SELECT prof_pic FROM users WHERE username = '{$_SESSION['MM_Username']}'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("Username not found in database."); $row = mysql_fetch_array($res); echo "<img src='$dir/{$row['prof_pic']}' width='38' height='38'><br>"; ?> I have some other code which allows users to post a message on my 'wall' The message is saved in my database in a 'messages' table with 3 columns: messageid, messgae, userid. The userid column is the same in my messages table as in my users table where the image is echo'd from. Can anybody help me write some code which will allow me to echo the images based on who created the message instead of who is logged in? Thanks in advance Hi all, I am completing an assignment for Uni and I have run it to a bit of difficulty. I hope someone can help me out. I am deleting a record from the database and I want it to then display the student record number, firstname and surname. I know it is probably something simple but I can see where I am going wrong! <?php $id=$_REQUEST['id']; $firstname=$_GET['firstname']; $surname=$_GET['surname']; $db="prs"; $link=mysql_connect("localhost","gandalf","bella") or die("Cannot Connect to the database!"); mysql_select_db($db,$link) or die ("Cannot select the database!"); $query="DELETE FROM students WHERE upn='".$id."'"; if(!mysql_query($query,$link)) {die ("An unexpected error occured while <b>deleting</b> the record, Please try again!");} else { echo "Student with Student Number #".$id." ".$firstname." ".$surname." removed successfully!";} ?>() Thanks in advance for any and all help, it is much appreciated. Cheers, Fergal Hi all I'm learning php and can't see where my error is in this simple code. I just want the country title to display with the states name below. here is the code. And thnk you for any help Code: [Select] // create arrays $_Mexico = array ('YU' => 'Yucatan', 'BC' => 'Baja California', 'QA' => 'Oaxaca'); $_US = array ('MD' => 'Maryland', 'IL' => 'Illinois', 'PA' => 'Pennsylvania', 'IA' => 'Iowa'); $_Canada = array ('QC' => 'Quebec', 'AB' => 'Alberta', 'NT' => 'North Territories', 'YT' => 'Yukon', 'PE' => 'Prince Edward Island'); // combine them $_N_america = array ('Mexico' => $_Mexico, 'United States' => $_US, 'Canada' => $_Canada ); // create loop foreach ($_N_america as $country => $list) { echo "<h2>$country</h2><ul>"; } foreach ($list as $k => $v) { echo "<li>$k - $v</li>\n"; } echo '</ul>'; I have used a tutorial to create an upload form for my website, it works fine until the file gets over 850 kb, how can I set it up so larg files 80 megs and up can be uploaded? Here is the simple code I am using,form Code: [Select] <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> PHP <html> Thanks <head> <title>My First PHP Page</title> </head> <body> <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> </body> </html> Good day people, got this open source script for a dog pedigree database on the net. I have no programming skills at all. Need some help with the script, i want to change the font color of the Sire's side of the pedigree that is displayed , but have no idea how to do it, any help would be appreciated. Example of displayed pedigree - http://www.sa-apbt.co.za/details.php?id=63854 below are the code. Thanks in advance <?php function DbTriad($dogVO, $level, $generations, $childText) { global $THUMBNAIL_WIDTH; global $dogDAO; # do the individual. if ($level == $generations) { echo "<TD >"; } else { echo "<TD ROWSPAN=" . pow(2,($generations - $level)); echo " >"; } if (($dogVO != -1) && (!empty($dogVO ))) { if (empty($dogVO)) { echo "Unknown Individual"; } else { $name = $dogVO->name; $sireId = $dogVO->sire->id; $damId = $dogVO->dam->id; $landofbirth = $dogVO->landofbirth; $yearofbirth = $dogVO->yearofbirth; $color = $dogVO->color; $title = $dogVO->title; $photo = $dogVO->photo->thumb_ref; if (empty($photo)) $photo = $dogVO->photo->reference; } ### Highlight title w/ Blue font if (!empty($title)) { echo "<label>"; echo "<font color=\"blue\">$title</font><BR>"; echo "</label>"; } echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$dogVO->id.'">'; if (!empty($photo)) { echo '<p><img SRC="'.$photo.'" width="'.$THUMBNAIL_WIDTH.'"></p>'; } echo "$name</a>"; echo "<label>"; //if (($level <= 3) && (!empty($color))) { if (!empty($color)) { echo "<BR>$color "; } if (!empty($landofbirth)) { echo "<BR>$landofbirth"; } if (!empty($yearofbirth)) { echo "<BR>$yearofbirth"; } echo "</label>"; } else { echo " "; if (!empty($childText) ) echo '<a href="addDog.php?child='.$childText.'">Add Dog</a>'; } echo "</TD>"; # do the father. if ($level < $generations) { if (!empty($dogVO)) $childText = "fatherOf_".$dogVO->id; else unset($childText); $dogDAO = new DogDAO(); if (empty($sireId)) $father = null; else $father = $dogDAO->get($sireId); DbTriad($father, $level + 1, $generations, $childText); } # do the mother. if ($level < $generations) { if (!empty($dogVO)) $childText = "motherOf_".$dogVO->id; else unset($childText); $dogDAO = new DogDAO(); if (empty($damId)) $mother = null; else $mother = $dogDAO->get($damId); DbTriad($mother, $level + 1, $generations, $childText); } # finish up. if ($level == $generations) { echo "</TR><TR>"; } } # begin table echo '<table id="pedigree" align="center" width="96%" border="0"><tr><th colspan='.$generations.'>Pedigree of '.$dog->name.' '.$dog->title.'</th></tr>'; # do tree. $dogDAO = new DogDAO(); $dog = $dogDAO->get($currId); DbTriad ($dog, 1, $generations, null); # end table echo "</td></tr></table>"; ?>[/php] I am brand new to php and the following code gives me an error of undefined variable although it seems to be defined. Please tell what I'm doing wrong cause this code comes from a book: <?php // Definition of the class Donation class Donation { private $name; private $amount; static $totalDonated = 0; static $numberOfDonors = 0; // Function to display what each person has donated function info() { $share = 100 * $this->amount / Donation::$totalDonated; return "{$this->name} donated {$this->amount} ({$share}%)"; } function __construct($nameOfDonor, $donation) { $this->name = $nameOfDonor; $this->amount = $donation; Donation::$totalDonated = Donation::$totalDonated + $donation; Donation::$numberOfDonors++; } function __destruct() { 109) Donation::$totalDonated = Donation::$totalDonated - $donation; Donation::$numberOfDonors--; } } It gives me the following error: Notice: Undefined variable: donation in C:\wamp\www\learnPHP\unitCounter.inc on line 109 Hello guys! My name is João Miquelis, Im from Portugal and I am a real noob in php, so i hope i can count with ur help |