dolrichfortich
Members-
Posts
32 -
Joined
-
Last visited
Everything posted by dolrichfortich
-
Cant figure why this wont insert to my database
dolrichfortich replied to cjohnson9's topic in PHP Coding Help
Okay, next time. -
Cant figure why this wont insert to my database
dolrichfortich replied to cjohnson9's topic in PHP Coding Help
Try this one. <?php if ($_SESSION['username']) { echo "<p><b>My Account</b><br /><br /> <a href=ah.php>Auburn Hills</a><br /> <a href=la.php>Los Angeles</a><br /> <a href=sc.php>San Carlos</a><br /> <a href=bos.php>Boston</a><br /> <a href=bna.php>Nashville</a><br /> <a href=logout.php>log out</a><br /> <a href=account.php>Account Settings</a></p>"; } ?> </p> </li> </ul> </li> <h4><span>About</span></h4> <ul> <li> <p style="margin: 0;"> This is system is in alpha stages of development...</p> </li> </ul> </li> <ul> <li></li> </ul> </div> <div id="content"> <div class="box"> <p><h3>Add New Machine</h3> <?php if ($_SESSION['username']) { echo "You are logged in as <u>".$_SESSION['username']."</u>!</p>"; } else { echo "Log In"; } ?> <form action="" method="POST"> <table border=1> <tr><td>Asset ID: *</td><td> <input type="text" name="asset_id" maxlength="10" size="10"> </td></tr> <tr><td>Location: *</td> <td> <select name="location"> <option value ="Auburn Hills"> Auburn Hills</option> <option value ="Los Angeles"> Los Angeles</option> <option value ="San Carlos"> San Carlos</option> <option value ="Boston"> Boston</option> <option value ="Nashville"> Nashville</option> </td></tr> <tr><td>Status: *</td> <td> <select name="status"> <option value ="active"> active</option> <option value ="spare"> spare</option> </td></tr> <tr><td>Type: *</td> <td> <select name="Type"> <option value ="desktop"> desktop</option> <option value ="laptop"> laptop</option> <option value ="server"> server</option> </td></tr> <tr><td>Manufacturer:</td> <td> <select name="make"> <option value ="Apple"> Apple</option> <option value ="Dell"> Dell</option> <option value ="HP"> HP</option> <option value ="IBM"> IBM</option> <option value ="Lenovo"> Lenovo</option> <option value ="Custom"> Custom</option> </td></tr> <tr><td>Model: *</td> <td> <select name="Model"> <option value ="MB Pro">MacBook Pro</option> <option value ="Mac Pro">Mac Pro</option> <option value ="Dimension D-620">Dimension D-620</option> <option value ="Dimension D-630">Dimension D-630</option> <option value ="Optiplex 745">Optiplex 745</option> <option value ="Optiplex 780">Optiplex 780</option> <option value ="Dimension M90">Dimension M90</option> <option value ="Dimension M6500">Dimension M6500</option> <option value ="Dimension E6410">Dimension E6410</option> <option value ="Dimension E6420">Dimension E6420</option> </td></tr> <tr><td>Amount of Ram:</td> <td> <select name="Ram"> <option value ="not sure"> not sure</option> <option value ="Under 1GB"> under 1GB</option> <option value ="1 GB"> 1 GB</option> <option value ="2 GB"> 2 GB</option> <option value ="3 GB"> 3 GB</option> <option value ="4 GB"> 4 GB</option> <option value ="8 GB"> 8 GB</option> <option value ="16 GB"> 16 GB</option> <option value ="24 GB"> 24 GB</option> <option value ="Above 24GB"> Above 24GB</option> </td></tr> <tr><td>Warranty:</td><td> <input type="text" name="warranty" maxlength="20" size="20"></td></tr> <tr><td>Username:</td><td> <input type="text" name="active_user" maxlength="8" size="8"></td></tr> <tr><td>Notes:</td><td> <input type="text" name="notes" maxlength="45" size="45"></td></tr> </table> <br> <input class="buttonSubmit" type="submit" name="addid" value="Add"> </form> <?php if($_SESSION['username']) { $con = mysql_connect("localhost","root","c3rb3ru5"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("gpj_asset", $con); //process the input into variables $submit = $_POST['addid']; $asset_id = strtolower(strip_tags(trim($_POST['asset_id']))); $location = strip_tags(trim($_POST['location'])); $active = strip_tags(trim($_POST['status'])); $platform = strip_tags(trim($_POST['Type'])); $make = strip_tags(trim($_POST['make'])); $model = strip_tags(trim($_POST['Model'])); $Ram = strip_tags(trim($_POST['Ram'])); $warranty = strip_tags(trim($_POST['warranty'])); $active_user = strip_tags(trim($_POST['active_user'])); $notes = strip_tags(trim($_POST['notes'])); if ($submit) { // Check for an existing asset $runThis = "SELECT * FROM assets WHERE asset_id = '$asset_id'"; //find the amount that match $count = mysql_num_rows($runThis); //Validate input $error = false; if ($count == 0) { if ( ! $asset_id OR ! $location OR ! $platform OR ! $active) { $error = "All * fields are required"; } else { //No input errors, run query $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } } } else { $error = 'Asset ID Exists!'; } //Check if any errors occured if($error !== false) { echo "<span style=\"color:red\"> {$error}</span>\n"; } else { echo "Asset Added Successfully"; } } } else echo " <form action=connect.php method=POST> <h3>Please Login <img src=\"images/0.410.gif\" /></h3> <table border=0> <tr><td>Username:</td><td> <input type=text name=username></td></tr> <tr><td>Password:</td><td> <input type=password name=password></td></tr></table> <input class=buttonSubmit type=submit name=submit value=submit></form>"; ?> -
Cant figure why this wont insert to my database
dolrichfortich replied to cjohnson9's topic in PHP Coding Help
You have some problem with your ordering of codes. //No input errors, run query $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; if (!$result) { die('Invalid query: ' . mysql_error()); } $result = mysql_query($query); This would be the correct order. Execute the query first before checking if it is successful or not. Are you not getting some php errors from your code? //No input errors, run query $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } -
Cant figure why this wont insert to my database
dolrichfortich replied to cjohnson9's topic in PHP Coding Help
You are using single qoutes for your table names. $query = "INSERT INTO assets ('asset_id, 'location', 'active', 'platform', 'make', 'model', 'Ram','warranty','active_user','notes') VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; Try this one and make sure you place it before you execute the query. $query = "INSERT INTO assets (`asset_id`, `location`, `active`, `platform`, `make`, `model`, `Ram`, `warranty`, `active_user`, `notes`) VALUES ('$asset_id','$location','$active','$platform','$make', '$model','$Ram','$warranty','$active_user', '$notes')"; -
That should be. $u=isset($_POST['u1']) ? $_POST['u1'] : ''; $p=isset($_POST['p1']) ? $_POST['p1'] : ''; isset($_POST['u1']) will return true or false and not the post variable.
-
First, when they have reached a page that is restricted, save first the url in a session before you redirect. $_SESSION['redirect_url'] = URL_OF_THE_PAGE; Here is a site which has a tutorial on getting the current url of a page. http://www.webcheatsheet.com/PHP/get_current_page_url.php Once they successfully logged in, check first if there is a redirect variable in the session. If there is a redirect variable, get the variable first, unset the redirect_url session, then redirect using the variable. If the redirect_url is not set, just redirect directly to index.php if(isset($_SESSION['redirect_ul'])) { $redirect_url = $_SESSION['redirect_ul']; unset($_SESSION['redirect_ul']); header('Location: ' . $redirect_url); exit; } else { header('Location: index.php'); exit; }
-
Help with sending Mail from PHP Using SMTP Authentication
dolrichfortich replied to oavs's topic in PHP Coding Help
Okay, try this one. Let me know if it works for you. <?php if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )) { $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else { $values = array ('name','email','phone','message'); $required = array('name','email','phone','message'); $from_email = 'abcd20@myowndomain.com'; $your_email = "abcd20@myowndomain.com"; $email_subject = "New Message: ".$_POST['subject']; $headers = "From: {$from_email}\r\nReply-To: {$from_email}"; $email_content = "New message:\n"; foreach($values as $key => $value) { if(in_array($value,$required)) { if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content, $headers)) { echo 'Message sent!'; } else { echo 'ERROR!'; } } ?> -
Help with sending Mail from PHP Using SMTP Authentication
dolrichfortich replied to oavs's topic in PHP Coding Help
Add additional parameter on the mail function to specify the email sender. Something like this. <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com'; mail($to, $subject, $message, $headers); ?> -
You can try this solution http://oohhyeah.blogspot.com/2009/01/google-currency-conversion-api.html Or this one http://www.google.com/finance/converter
-
Try this one. $pass = isset($_GET['pass']) ? $_GET['pass']:''; $login = isset($_GET['login']) ? $_GET['login']:''; $id = isset($_GET['ID']) ? $_GET['ID']:''; if($_POST) { $pass = isset($_POST['pass']) ? $_POST['pass']:''; $login = isset($_POST['login']) ? $_POST['login']:''; $id = isset($_POST['ID']) ? $_POST['ID']:''; }
-
Try the file attached. [attachment deleted by admin]
-
Strange issue (arrays and classes)
dolrichfortich replied to Ninjakreborn's topic in PHP Coding Help
Probably not because you cannot create a variable or a function using numbers only. -
Try this one. I wonder why the code from neil.johnson didnt work. function cname($pubid) { global $db; $company= $db->query("SELECT * FROM my_database WHERE id='$pubid'") or die(mysql_error()); $company= $db->fetch_array($company); return $company['name']; }
-
Try adding this to check if the database class is really returning any data. function cname($pubid) { global $db; $company= $db->query("SELECT * FROM my_database WHERE id='$pubid'") or die(mysql_error()); print_r($db->fetch_array($company)); while($company= $db->fetch_array($company)) { $cname = $company['name']; } return $cname; }
-
simple image slideshow not working in php
dolrichfortich replied to silverglade's topic in PHP Coding Help
Hahaha. Glad I could help. Just send me a message if you need help with your money making ideas in mind. By the way, heres an explanation of the single line code I used. http://www.tuxradar.com/practicalphp/3/12/4 -
simple image slideshow not working in php
dolrichfortich replied to silverglade's topic in PHP Coding Help
Hahaha. By the way, heres the fix. Change this code $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background']); To this $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background'])-1; To force it to start with the first image. Use this code if(( ! isset($_SESSION['current_background'])) OR (! $_POST)) { $_SESSION['current_background'] = 0; } -
Retrieve results from mysql as array and echo it out
dolrichfortich replied to Danbannan's topic in PHP Coding Help
array($result) will not give you the data in the resource. You will need to use mysql_fetch_array or similar function to get those data. Here is a sample code. <?php $con = mysql_connect('localhost',$user,$pass)or die(mysql_error()); $selectdb = mysql_select_db($selectdb)or die(mysql_error()); $sql = "SELECT * From table"; $result = mysql_query($sql); //This loops until mysql_fetch_array returns false //which means you have reached the last row while ($row = mysql_fetch_array($result)) { print_r($row); } ?> -
What was the error you are getting?
-
simple image slideshow not working in php
dolrichfortich replied to silverglade's topic in PHP Coding Help
Oh, its you. How was your photography site? By the way, try this one. This should work. <?php session_start(); if (!isset($_SESSION['background'])) { $_SESSION['background'] = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ); } if(!isset($_SESSION['current_background'])) { $_SESSION['current_background'] = 0; } if(isset($_POST['further'])) { $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] + 1]) ? ($_SESSION['current_background'] + 1) : 0; } elseif(isset($_POST['back'])) { $_SESSION['current_background'] = isset($_SESSION['background'][$_SESSION['current_background'] - 1]) ? ($_SESSION['current_background'] - 1) : count($_SESSION['background']); } $currentBackground=$_SESSION['background'][$_SESSION['current_background']]; ?> <!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> </head> <body> <?php echo $currentBackground;?> <form action='NAVIGATION.php' method='post'> <input type="submit" value="go further" name="further" /> <input type="submit"value="Go back" name="back"/></form> </body> </html> -
simple image slideshow not working in php
dolrichfortich replied to silverglade's topic in PHP Coding Help
How about this. <?php session_start(); if (!isset($_SESSION['background'])) { $_SESSION['background'] = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>" ); } if(isset($_POST['further'])) { $currentBackground=next($_SESSION['background']); } elseif(isset($_POST['back'])) { $currentBackground=prev($_SESSION['background']); } else { $currentBackground=$_SESSION['background'][0]; } ?> <!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> </head> <body> <?php echo $currentBackground;?> <form action='NAVIGATION.php' method='post'> <input type="submit" value="go further" name="further" /> <input type="submit"value="Go back" name="back"/></form> </body> </html> -
There are many php scripts for this on the web. Try this one. http://www.merchantos.com/makebeta/php/scraping-links-with-php/
-
Form processing not running database commital code.
dolrichfortich replied to TGWSE_GY's topic in PHP Coding Help
Try this code. You have some missing } for your if conditions. <?php $dbserver = "localhost"; $dbuname = "vri_dev"; $dbpword = "emit098nice054"; $con = mysql_connect($dbserver, $dbuname, $dbpword); if(!$con) { die('Could not connect to the database server :' . mysql_error()); } else { echo"1.2"; //Select Database mysql_select_db("vri_inkcontrol", $con); //Get idcname $q = "SELECT idcname FROM `tbl_hosting_cname` WHERE cname='{$_POST['cname']}' AND dname='{$_POST['dname']}'"; $r = mysql_query($q); //Put idcname query into an array $r_array = mysql_fetch_assoc($r); //Store idcname result from previouse query $idcname = $r_array['idcname']; //trap duplicate records //If the number of rows returned by above query is not greater then we if(mysql_num_rows($r) == 0) { echo"2"; //Insert idcname in `tbl_hosting_cname` since id doesn't exist $q = "INSERT INTO `tbl_hosting_cname` SET cname='{$_POST['cname']}'"; mysql_query($q); //grab the cname id in `tbl_hosting_cname` $q = "SELECT idcname FROM `tbl_hosting_cname WHERE cname='{$_POST['cname']}'"; $r = mysql_query($q); //now we must grab the id cname from array $q = "SELECT idcname FROM `tbl_hosting_cname` WHERE cname='{$_POST['cname']}'"; $r = mysql_query($q); $row = mysql_fetch_assoc($r); $idcname = $row['idcname']; $r = mysql_query("SELECT * FROM `tbl_hosting_domain` WHERE cname='{$idcname}' AND dname='{$_POST['dname']}'"); if(mysql_num_rows($r) !== 1) { echo"3"; $q = "INSERT INTO `tbl_hosting_domain` (idcname, dname, ip, ns1, ns2, ftpaddress, ftpuname, ftppword, pop, smtp, webmailaddress, diskspace, bandwidth, nummailboxes, mailboxquota, numdatabases, exp) VALUES ('{$idcname}', '{$_POST['dname']}', '{$_POST['ip']}', '{$_POST['ns1']}', '{$_POST['ns2']}', '{$_POST['ftpserver']}', '{$_POST['ftpuname']}', '{$_POST['ftppword']}', '{$_POST['pop']}', '{$_POST['smtp']}', '{$_POST['webmailaddy']}', '{$_POST['adiskspace']}', '{$_POST['ambw']}', '{$_POST['amboxes']}', '{$_POST['amboxesquota']}', '{$_POST['adbases']}', '{$_POST['exp']}')"; mysql_query($q); $route = "Location: index.php?section=newaddyes"; } elseif(mysql_num_rows($r) == 1) { echo"3.2"; $q = "SELECT idcname FROM `tbl_hosting_cname` WHERE cname='{$_POST['cname']}'"; $r = mysql_query($q); $row = mysql_fetch_assoc($r); $idcname = $row['idcname']; $q = "UPDATE `tbl_hosting_domain` SET ( ip = '{$_POST['ip']}', ns1 = '{$_POST['ns1']}', ns2 = '{$_POST['ns2']}', ftpaddress = '{$_POST['ftpserver']}', ftpuname = '{$_POST['ftpuname']}', ftppword = '{$_POST['ftppword']}', pop = '{$_POST['pop']}', smtp = '{$_POST['smtp']}', webmailaddress = '{$_POST['webmailaddy']}', diskspace = '{$_POST['adiskspace']}', bandwidth = '{$_POST['ambw']}', nummailboxes = '{$_POST['amboxes']}', mailboxquota = '{$_POST['amboxesquota']}', numdatabases = '{$_POST['adbases']}', exp = '{$_POST['exp']}' WHERE cname='{$idcname}'"; $route = "Location: index.php?section=newaddyes"; } else { echo"lsr1"; $route = "Location: index.php?section=newaddno"; } } } -
Replace your code $query = "UPDATE CollegeFootballPicks SET User_ID = '$Current_user_id', Game_ID = '$gameF', Pick = '$pickF'"; With this code $query = "UPDATE CollegeFootballPicks SET Pick = '$pickF'" WHERE User_ID='$Current_user_id' AND Game_ID='$gameF';
-
To return the submitted in for selectbox, the code is like this. <?php function post($fieldname, $default = '') { return isset($_POST($fieldname)) ? $_POST[$fieldname]:$default; } ?> <select name="DateOfBirth_Month"> <option <?php echo post('DateOfBirth_Month')==1?'SELECTED':''?> value="1">January</option> <option <?php echo post('DateOfBirth_Month')==2?'SELECTED':''?> value="2">February</option> </select> <select id = "DateOfBirth_Day" name="DateOfBirth_Day"> <option>Day</option> <?php for($i=1;$i<=31;$i++) { ?> <option <?php echo post('DateOfBirth_Day')==1?'SELECTED':''?>value="<?php echo $i?>"><?php echo $i?></option> <?php } ?> </select> <select id = "DateOfBirth_Year" name="DateOfBirth_Year"> <option>Year</option> <?php for($i=2010;$i>=1900;$i--) { ?> <option <?php echo post('DateOfBirth_Year')==1?'SELECTED':''?>value="<?php echo $i?>"><?php echo $i?></option> <?php } ?> </select>