PHP - Newbie Need Help In Php Script Please
i've tried this php script in html
<head> <title>A BASIC HTML FORM</title> <? PHP $username = $_POST['username']; if ($username == "holier") { print("Welcome back, friend!!"); } else { print("You're not a memeber of this site"); } ?> </head> but nothing showing at the top of page tell me why please ? Similar TutorialsHi, I am very new to PHP (and web developing generally, as well). I have been passing through two different ways of verifying user input in a PHP webpage: 1- By calling a different script file, where the verification logic code is listed and then recall the referer $_SERVER['HTTP_REFERER'] page and pass the result using $_SESSION. (I understood this is basically done to avoid repeating the action in the code with every refreshment of the browser window). 2- By enclosing the verification logic code withing the same PHP page, so the page is a big mix of HTML & PHP. (I understood this is basically done, in order to keep the user input without using $_SESSION and it should save one trip of data transfer.) For me, I see both are working; still I want to learn the best coding practices. So your advice is appreciated, and please feel free to correct my, if I missed something about both methods. Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> Hi i have this upload script which works fine it uploads image to a specified folder and sends the the details to the database. but now i am trying to instead make a modify script which is Update set so i tried to change insert to update but didnt work can someone help me out please this my insert image script which works fine but want to change to modify instead Code: [Select] <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("upload") or die(mysql_error()) ; // my file the name of the input area on the form type is the extension of the file //echo $_FILES["myfile"]["type"]; //myfile is the name of the input area on the form $name = $_FILES["image"] ["name"]; // name of the file $type = $_FILES["image"]["type"]; //type of the file $size = $_FILES["image"]["size"]; //the size of the file $temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name $error =array(); // this an empty array where you can then call on all of the error messages $allowed_exts = array('jpg', 'jpeg', 'png', 'gif'); // array with the following extension name values $image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); // array with the following image type values $location = 'images/'; //location of the file or directory where the file will be stored $appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif // substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg //echo $extension = substr($name, 3); //using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif $extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg // another way of doing is with explode // $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode $myfile = $_POST["myfile"]; if (isset($image)) // if you choose a file name do the if bellow { // if extension is not equal to any of the variables in the array $allowed_exts error appears if(in_array($extension, $allowed_exts) === false ) { $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line } // if file type is not equal to any of the variables in array $image_type error appears if(in_array($type, $image_type) === false) { $error[] = 'Type of file not allowed! only images allowed<br />'; } // if file bigger than the number bellow error message if($size > 2097152) { $error[] = 'File size must be under 2MB!'; } // check if folder exist in the server if(!file_exists ($location)) { $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location; } } // if no error found do the move upload function if (empty($error)){ if (move_uploaded_file($temp, $location .$appendic_name)) { // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image mysql_query("INSERT INTO image (myfile ,image) VALUES ('$myfile', '$appendic_name')") ; exit(); } } else { foreach ($error as $error) { echo $error; } } //echo $type; ?> 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 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 I need the following XML code http://primarymortgages.co.uk/dev/property-xml-donotdelete.xml to be entered into the database, while I have done the first bit... <code> # address - basic info if(is_object($xml->address)) { foreach($xml->address as $address) { $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)) { $long = $xml->longitude; $lat = $xml->latitude; $type = $xml->type; $furnished = $xml->furnished; $bedrooms = $xml->bedrooms; $bathrooms = $xml->bathrooms; $description = $xml->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); } </code> I need to be able to get the 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> etc, etc... However the following code isn't working for me... <code> # paragraphs print_r ($xml->paragraph); foreach($xml->paragraph as $paragraph) { $thetitle = $paragraph->title; $thetext = $paragraph->text; $insertS = "INSERT INTO $tablec (pal, afield, bfield, atext) VALUES (111, '$iid', '$thetitle', '$thetext')"; $insertQ = mysql_query($insertS); print "<p>$insertS</p>"; } </code> Can someone adjust the # paragraphs code for me so it can work Many Thanks. 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>"; } } } } ?> I would love to find someone that I can ask all my annoying narbish questions to. Code: [Select] $username="a1624814_bento"; $password="Password123"; $database="a1624814_siteDB"; $localhost="mysql13.xxx.xxx"; mysql_connect($localhost,$user,$password); line 13 Code: [Select] mysql_connect($localhost,$user,$password); Quote Host '31.100.100.200 is not allowed to connect to this MySQL server in /home/member/insert.php on line 13 Now after I fix this, Im sure that I will hafve a string of other failiurs, what do i do with them? some i can figure out, and normally will try to figure something out before asking. Thanks for taking the time to read!!! 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. Hey guys, i'm not just new here but i'm new to php.. I've been trying to edit some wordpress templates i was given, but there is some code in the footer/copyright files that i really don't understand at all .. Here is an example of the code ... Code: [Select] <?php $_F=__FILE__;$_X='Pz4JCQkJCTxkNHYgNGQ9ImYyMnQ1ciI+DQoJCQkJCQkNCgkJCQkJCTxwIGNsMXNzPSJjMnB5cjRnaHQiPkMycHlyNGdodCAmYzJweTsgYTAwOCAtIDwxIGhyNWY9Imh0dHA6Ly8xc3MzcjFuYzVjMm1wbDVtNW50MTRyNXMxbnQ1LjJyZyIgdDR0bDU9ImQ1djRzIGMybXBsNW01bnQxNHI1IHMxbnQ1IGMybXAxcjF0NGYgMXNzM3IxbmM1IG0xbDFkNDUgbTN0MzVsbDUiPmQ1djRzIGMybXBsNW01bnQxNHI1IHMxbnQ1IGMybXAxcjF0NGYgMXNzM3IxbmM1IG0xbDFkNDUgbTN0MzVsbDU8LzE+PC9wPg0KCQkJCQkJDQoJCQkJCQk8cCBjbDFzcz0icDJ3NXI1ZCI+DQogICAgICAgICAgICAgICAgICAgICAgICA8MSBocjVmPSJodHRwOi8vczRtM2wxdDQybjFzczNyMW5jNXY0NS5jMm0iIHQ0dGw1PSJzNG0zbDF0NDJuIDFzczNyMW5jNSB2NDUgcjVuZDVtNW50IG0zbHQ0c3MzcDJydCB0MTN4IGMybXAxcjF0NGYiIGNsMXNzPSJ3MjJ0aDVtNXMiPiZuYnNwOzwvMT4NCiAgICAgICAgICAgICAgICAgICAgICAgIDwvcD4NCgkJCQkJDQoJCQkJCTwvZDR2PjwhLS0gRW5kIGYyMnQ1ciAtLT4=';eval(base64_decode('JF9YPWJhc2U2NF9kZWNvZGUoJF9YKTskX1g9c3RydHIoJF9YLCcxMjM0NTZhb3VpZScsJ2FvdWllMTIzNDU2Jyk7JF9SPWVyZWdfcmVwbGFjZSgnX19GSUxFX18nLCInIi4kX0YuIiciLCRfWCk7ZXZhbCgkX1IpOyRfUj0wOyRfWD0wOw=='));?> Could someone please explain if there is a way of decoding this?? Thanks so much HI guyz, want help in a code that can help find the GCD of two input numbers Use the example of GCD (12,15). 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
Hello all, I'm a basic coder 😀 if($_POST['form']['hobby'] == '')  $modUserEmailText = str_replace('{hobby:caption} : {hobby:value}', ''<br/>'',$modUserEmailText);
{hobby:caption} : {hobby:value} Thanks a million! 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> <?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? 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] 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 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>'; |