Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. hi ive encountered around 15 problems at once but just about all of them are on the same row <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["companyname"])) {$errors['companyname'] = "please enter your companys name";} else {$companyname = test_input($_POST["companyname"]);} if (empty($_POST["typeofbusiness"])) {$errors['typeofbusiness'] = "please enter your TypeofBusiness";} else {$typeofbusiness = test_input($_POST["typeofbusiness"]);} if (empty($_POST["firstname"])) {$errors['firstname'] = "Please Enter Your First Name";} else {$firstname = test_input($_POST["firstname"]);} if (empty($_POST["address1"])) {$errors['address1'] = "Please Enter Address 1";} else {$address1 = test_input($_POST["address1"]);} if (empty($_POST["address2"])) {$address2 = test_input($_POST["address2"]);} if (empty($_POST["area"])) {$errors['area'] = "Please enter Area";} else {$area = test_input($_POST["area"]);} if (empty($_POST["city"])) {$errors['city'] = "Please Enter City";} else {$city = test_input($_POST["city"]);} if (empty($_POST["postcode"])) {$errors['postcode'] = "Please enter your PostCode";} else {$postcode = test_input($_POST["postcode"]);} if (empty($_POST["email"])) {$errors['email'] = "Please enter your Email";} else {$email = test_input($_POST["email"]);} if (empty($_POST["Website"])) {$errors['Website'] = "Please Enter your Website";} else {$Website = test_input($_POST["Website"]);} if (empty($_POST["ClubNumber"])) {$errors['clubnumber'] = "Please enter your club number";} else {$website = test_input($_POST["clubphone"]);} if (empty($_POST["HomeNumber"])) {$errors['homenumber'] = "Please enter your home number";} else {$website = test_input($_POST["homephone"]);} if (empty($_POST["MobileNumber"])) {$errors['mobilenumber'] = "Please enter your mobile number";} else {$website = test_input($_POST["mobilephone"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Add Leads</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>Company Name:</td><td> <input type="text" name="companyname"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>type of business:</td><td> <input type="text" name="typeofbusiness"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php if (isset($errors['firstname'])) echo $errors['firstname']; ?></span></td> </tr> <tr> <td>Address 1:</td><td> <input type="text" name="address1"></td> <td><span class="error">* <?php if (isset($errors['address1'])) echo $errors['address1']; ?></span></td> </tr> <tr> <td>Address 2:</td><td><input type="text" name="address2"></td> </tr> <tr> <td>Area:</td> <td><input type="text" name="area"></td> <td><span class="error">* <?php if (isset($errors['area'])) echo $errors['area']; ?></span></td> </tr> <tr> <td>PostCode:</td> <td><input type="text" name="postcode"></td> <td><span class="error">* <?php if (isset($errors['postcode'])) echo $errors['postcode']; ?></span></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city"></td> <td><span class="error">* <?php if (isset($errors['city'])) echo $errors['city']; ?></span></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email"></td> <td><span class="error">* <?php if (isset($errors['email'])) echo $errors['email']; ?></span></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website"></td> <td><span class="error">* <?php if (isset($errors['website'])) echo $errors['website']; ?></span></td> </tr> <tr> <td>Club phone:</td> <td><input type="text" name="clubphone"></td> <td><span class="error">* <?php if (isset($errors['clubphone'])) echo $errors['clubphone']; ?></span></td> </tr> <tr> <td>home phone:</td> <td><input type="text" name="homephone"></td> <td><span class="error">* <?php if (isset($errors['homephone'])) echo $errors['homephone']; ?></span></td> </tr> </tr> <tr> <td>mobile phone:</td> <td><input type="text" name="mobilephone"></td> <td><span class="error">* <?php if (isset($errors['mobilephone'])) echo $errors['mobilephone']; ?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?php if (count($errors)==0) { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 ?> </form> </body> </html> and the errors ( ! ) Notice: Undefined variable: errors in C:\wamp\www\AddLeads\addeadstemplate.php on line 161 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: companyname in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: firstname in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: address1 in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: address2 in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: area in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: city in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: postcode in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: email in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: website in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: clubphone in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: homephone in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: mobilephone in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: typeofbusiness in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 Error: Column count doesn't match value count at row 1 if anyone can help please get back to me soon as
  2. Hello, I am trying to write a bit of code that will open a different page url depending on whether the value in my 'newsimage' table is set to left, right or centre. There is a news page which contains a list of news snippets and when you click 'read more' it should direct to one of three pages depending on where the 'image' should sit. The PHP is in a seperate file to the news page. This is the code that should display the news snippets. <div id="sectionright"> <div class="sectionhead"> <h2 class="sect editable" id="h2top">Media</h2> </div> <div class="padder18"></div> <?php newsform(); top10news($s,$t,$u,$w); ?> </div> This is the code in the seperate PHP file that displays the content. function top10news($s, $t, $u, $w) { $con = mysqli_connect("ip", "server", "password", "database name"); if (mysqli_connect_errno($con)) { echo "<p class='sect'>Could not connect to DB</p>"; // echo "<p class='sect'>Could not connect to DB " . mysqli_connect_error() . "</p>"; } else { // echo "<p class='sect'>Connected to DB</p>"; $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage FROM newsitem,newsbusiness WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' "; if ("$u" == "Any") { } else { $q = $q . "AND sitename='$u' "; } if ("$s" == "Any") { } else { $parts = explode('-', $s); $y = $parts[0]; $m = $parts[1]; $q = $q . "AND YEAR(newsdate) = $y AND MONTH(newsdate) = $m "; } $q = $q . "ORDER BY newsdate DESC LIMIT 0,10"; // echo "<p class='news'>$s</p>"; // echo "<p class='news'>$q</p>"; $result = mysqli_query($con, $q); while ($tnrow = mysqli_fetch_array($result)) { echo " <div class='newssummary'>"; if ("" . $tnrow['newsimage'] . "" == "none") { echo <p class = 'newsmore' > < a href = 'newsitem.php?i=" . $tnrow['niid'] . "' > Read More</a > </p>; }else $radio = mysqli_query("SELECT imageposition FROM newsimage WHERE imageposition EQUALS newsitem.niid=newsimage.niid"); $qresult = mysqli_query($con, $radio); while (($tnrow = mysqli_fetch_array($qresult)); { if ($radio == 'Centre') { echo "<p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Right') { echo "<p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Left') { echo "<p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } } mysqli_close($con); } My problem is that whenever I load the page it just produces a blank page. When I look at the source code on the web all that is displayed is "<!doctype html>" However, when I remove the second query from the file and re-upload it, it all works fine, so from what I can gather there is a problem some where in this bit of code: }else $radio = mysqli_query("SELECT imageposition FROM newsimage WHERE imageposition EQUALS newsitem.niid=newsimage.niid"); $qresult = mysqli_query($con, $radio); while (($tnrow = mysqli_fetch_array($qresult)); { if ($radio == 'Centre') { echo "<p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Right') { echo "<p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Left') { echo "<p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } } mysqli_close($con); } I just can't see why it isn't working.... Whenever I run the debugger I am only receiving this error message "Parse error: syntax error, unexpected '<' in C:\pathway\filename.php on line 32" which isn't really useful because when I look at line 32 there are no added '<' Advice would be much appreciated before I start tearing my hair out lol!
  3. why unexpected end of file on line 49: <html> <?php session_start(); if(isset($_POST['submit'])){ if (isset($_SESSION['email'])) { $uid=$_SESSION['uid']; $con=mysql_connect("localhost","root","")or die(mysql_error()); mysql_select_db("regis")or die(mysql_error()); $add1=$_POST['add1']; $add2=$_POST['add2']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; if (isset($_POST['set'])){ $sett=$_POST['set']; } //check if the default address is already set. $check = mysql_query("SELECT uid FROM address WHERE uid = '$uid' and sett='1' ") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the default already set, it gives an error if ($check2 != 0) { die('Sorry, the default is already set.would you like to change it'); $display_block=<<<END_OF_BLOCK <form action="update.php" method="POST"> <h2>Would you like to change your default address</h2> yes:<input type="radio" name="update" value="1"><br/> No:<input type="radio" name="update" value="0"><br/> <input type="submit" value="submit" name="submit"> </form> END_OF_BLOCK; } else if($check2 == 0){ mysql_query("INSERT INTO address (uid, add1, add2, city, state, country ,sett ) VALUES ('$uid', '$add1','$add2' ,'$city' ,'$state' ,'$country' , '$sett' )") or die(mysql_error()); echo "Your address get saved in our Database"; echo "<br/>"; } } } ?> <a href="logout.php">logout</a><br/> <a href="add_address.php">Would you like to add another address</a><br/> <a href="default.html">Next Page</a> </html>
  4. I'm trying to integrate CKEditor into my simple CMS. I got it to show up in the right spot, but there is another instance of the editor open at the top of the page, and I can't figure out why. Here is my code: <?php require_once 'conn.php'; include_once 'ckeditor/ckeditor.php'; $CKEditor = new CKEditor(); $CKEditor->editor('body'); $title= ''; $body= ''; $article= ''; $author_id= ''; if (isset($_GET['a']) and $_GET['a'] == 'edit' and isset($_GET['article']) and $_GET['article']) { $sql = "SELECT title, body, author_id FROM cms_articles " . "WHERE article_id=" . $_GET['article']; $result = mysql_query($sql, $conn) or die ('Could not retrieve article data: ' . mysql_error()); $row = mysql_fetch_array($result); $title = $row['title']; $body = $row['body']; $article = $_GET['article']; $author_id = $row['author_id']; } require_once 'header.php'; ?> <form method="post" action="transact-article.php"> <h2>Compose Article</h2> <p> Title: <br /> <input type="text" class="ckeditor" name="title" maxlength="255" value="<?php echo htmlspecialchars($title); ?>" /> </p> <p> Body: <br /> <textarea class="ckeditor" name="body" id="ckeditor"><?php echo htmlspecialchars($body); ?></textarea> </p> <p> <?php echo '<input type="hidden" name="article" value="' . $article . "\" />\n"; if ($_SESSION['access_lvl'] < 2) { echo '<input type="hidden" name="author_id" value="' . $author_id . "\" />\n"; } if ($article) { echo '<input type="submit" class="submit" name="action" ' . "value=\"Save Changes\" />"; } else { echo '<input type="submit" class="submit" name="action" ' . "value=\"Submit New Article\" />"; } ?> </p> </form> <?php require_once 'footer.php'; ?> Any help is MUCH appreciated!
  5. this is my html file.when i am submitting the file it shows : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set) VALUES ('', '11','11' ,'nashik' ,'mh' ,'india', '1' )' at line 1 why it is so.any suggestions........ add_address.html <html> <head> <title>Add Address</title> </head> <body> <table border="1" cellspacing="2" cellpadding="0"> <tr><td> <h2>Add Address here</h2></td></tr> <form action="add_address.php" method="POST"> <tr><td> Add1:<input type="text" name="add1" id="add1"><br/> </td></tr> <tr><td> Add2:<input type="text" name="add2" id="add2"><br/> </td></tr> <tr><td> City:<input type="text" name="city" id="city"><br/> </td></tr> <tr><td> State:<input type="text" name="state" id="state"><br/> </td></tr> <tr><td> Country:<input type="text" name="country" id="country"><br/> </td></tr> <tr><td> <h2>would you like to make it default address</h2> </td></tr> <tr><td> Yes:<input type="radio" name="set" value="1" id="set"><br/> </td></tr> <tr><td> No:<input type="radio" name="set" value="0" id="set"><br/> </td></tr> <tr><td> <input type="submit" name="submit" value="submit"><br/> </td></tr> </form> </body> </html> add_address.php <?php session_start(); if(isset($_POST['submit'])){ if (isset($_SESSION['email'])) { $uid=$_SESSION['uid']; $con=mysql_connect("localhost","root","")or die(mysql_error()); mysql_select_db("regis")or die(mysql_error()); $add1=$_POST['add1']; $add2=$_POST['add2']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; if (isset($_POST['set'])){ $set=$_POST['set']; } mysql_query("INSERT INTO address (uid, add1, add2, city, state, country, set) VALUES ('$uid', '$add1','$add2' ,'$city' ,'$state' ,'$country', '$set' )") or die(mysql_error()); echo "Your address get saved in our Database"; echo "<br/>"; }} ?> <a href="logout.php">logout</a><br/> <a href="add_address.php">Would you like to add another address</a><br/> <a href="default.html">Next Page</a>
  6. Ok , so I am developing a web application that's going to let people connect through Facebook , Twitter or Google plus ... Now , the api code is located in three respective different folders , facebook folder for the facebook api , twitter folder for twitter and google_plus.. The thing is , I'm trying to make people be able to log through Twitter and access the application .. and give them the option to also logon through Facebook after logging through Twitter and keep the twitter-based data after they logged through Facebook , I would basically like them to be able to view both their twitter and facebook feeds mixed together at the same time ... I tried to implement sessions , but it looks like if they log through Facebook after logging through twitter first , the Twitter session variable content become NULL and only facebook session data is displayed .. How can I manipulate the sessions so that twitter data can be kept when a user log through facebook as well ? Below is what I did to test the data .. <?php session_set_cookie_params('3600'); session_start(); require('../database/connection.php'); require_once('../twitter/twitteroauth/twitteroauth.php'); require_once('../twitter/config.php'); include_once '../facebook/fbmain.php'; // Here I'll test the $_SESSION variable to see if twitter data is kept after a user logs through facebook as well .. but twitter data become NULL instead and the $_SESSION array only show facebook data .. How can I make twitter session data STAY after someone logs through facebook as well ? var_dump($_SESSION); var_dump(session_id()); /* If access tokens are not available redirect to connect page. */ if (empty($_SESSION['facebook_id']) && (empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret']))) { header('Location: ./clearsessions.php'); } else { /* Get user access tokens out of the session. */ $access_token = $_SESSION['access_token']; /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); /* If method is set change API call made. Test is called by default. */ $content = $connection->get('account/verify_credentials'); $json = json_encode($content); $data = json_decode($json,true); $screen_name = $data["screen_name"]; $name = $data["name"]; $image_url = $data['profile_image_url']; $_SESSION['screen_name'] = $screen_name; $_SESSION['image_url'] = $image_url; $query = "SELECT * FROM Users WHERE username ='$screen_name'"; $result = mysql_query($query); $result_count = mysql_num_rows($result); if($result_count == 0) { $insert = "INSERT INTO Users(username) VALUES('$screen_name')"; $result_insert = mysql_query($insert); } } if(isset($_SESSION['oauth_token']) && isset($_SESSION['oauth_token_secret']) && isset($_SESSION['facebook_id'])){ $user = $_SESSION['facebook_id']; } ?>
  7. i got undefined var errors on line no 26,27,28 for variables fname,lname,phone.how they can be undefined they are getting retrived by mysql.how to remove these errors. <?php session_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="regis"; // Database name $tbl_name="regis"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if(isset($_SESSION['email'])) $email=$_SESSION['email']; { $query="SELECT fname,lname,phone,email FROM regis WHERE email='$email'"; $result=mysql_query($query); $num=mysql_fetch_array($result);} ?> <table width="600" cellpadding="10" cellspacing="0" border="2"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1"> <form action="update.php" method="POST"> <input type="hidden" name="email" value="<?php echo "$email"?>"> <input type="text" name="fname" value="<?php echo "$fname"?>"> <input type="text" name="lname" value="<?php echo "$lname"?>"> <input type="text" name="phone" value="<?php echo "$phone"?>"> <input type="submit" value="submit"> </form></td></tr></table>
  8. the session var email is not saves as when ai am using if-else to check session isset it goes to else clause why it is so and how i can save my session. <?php session_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="regis"; // Database name $tbl_name="regis"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $email=$_POST['email']; $pass=$_POST['pass']; // To protect MySQL injection (more detail about MySQL injection) $email = stripslashes($email); $pass = stripslashes($pass); $email = mysql_real_escape_string($email); $pass = mysql_real_escape_string($pass); $sql="SELECT * FROM $tbl_name WHERE email='$email' and pass='$pass'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $email and $pass, table row must be 1 row if($count==1){ $_session['email']="$email"; else { echo "Wrong Username or Password"; } if(isset($_SESSION['email'])) echo "amit"; else echo "other"; } ?>
  9. I am on the first year at college studying computer science and they sent me to write a php program that can change a decimal number to IEEE754 standard on 16bits. I know most of you will laugh because it is very easy but I need help. this is what i got so far. ALL i need is how to control the mantissa.. you know, save 10 numbers.. and how to control the while loop so he stops when i have 10 spots on mantissa.. <?php echo "Enter any number\n"; $number=trim(fgets(STDIN)); $low=floor($number); $decimal=$number - $low; $real=decbin($low); while(0<$decimal<1) { $mantissa[]=$decimal*2; } echo "\n"; ?>
  10. Suppose, I have a table that has one million rows in it. That particular table has information related to people of particular country. It has few fields like user_id, name, phone, address, email address and some relevant fields like that. I am keeping user_id as primary key [which is unique]. Table name is people_record. There is no join or stuff like that, I am asking for the simple query. Now, my question is, I have to search single record in a table that has one million rows. So, if I search one record in that table using one user_id, how much time will it take with mysql. The query that I am executing is : select * from people_record where user_id=AAAA_00001 Will this query provide the output fast or I have to use some searching and sorting techniques to sort the database. I am asking the question here to know the better way to query a single row out of one million rows, I have listed the query above and want to know if there is something that i can do here to retrieve the result faster ???? Looking forward for the best solution..............Thanks
  11. Hello. I am having some trouble and I'm not sure if its my code or logic haha. Basically, my company has commissoned a website for one of our clients and used an outside developer to actually build the site. Now the initial development is complete I have been put in charge of the support and maintenance of the site. However the client has now decided they would like to decide the position of an image on the news pages. To display a news article, they enter the information in a form, which is saved in the database, this is then recalled through a php script when a user clicks 'read more' on the website. I have added a set of radio buttons to the form where the client can select if the image is Right, Left of Centre. When they save the form this information is saved in the database. I then want to create a script that will open the 'newsitem' 'newsitem2' or 'newsitem3' page depending on the value of the radio button. This is the code I am using: function top10news($s, $t, $u, $w) { $con = mysqli_connect("ip", "host", "password", "databasename"); if (mysqli_connect_errno($con)) { echo "<p class='sect'>Could not connect to DB</p>"; // echo "<p class='sect'>Could not connect to DB " . mysqli_connect_error() . "</p>"; }else { // echo "<p class='sect'>Connected to DB</p>"; $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage FROM newsitem,newsbusiness WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' "; if ("$u" == "Any") { }else { $q = $q . "AND sitename='$u' "; } if ("$s" == "Any") { }else { $parts = explode('-', $s); $y = $parts[0]; $m = $parts[1]; $q = $q . "AND YEAR(newsdate) = $y AND MONTH(newsdate) = $m "; } $q = $q . "ORDER BY newsdate DESC LIMIT 0,10"; // echo "<p class='news'>$s</p>"; // echo "<p class='news'>$q</p>"; $result = mysqli_query($con, $q); while ($tnrow = mysqli_fetch_array($result)) { echo " <div class='newssummary'>"; if ("" . $tnrow['newsimage'] . "" == "none") { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } else { $radio= "SELECT imageposition FROM newsimage"; if ($radio == 'Centre') { <p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Right') { <p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Left') { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } } mysqli_close($con); } The problem I am facing is when I then go to load the news page. Nothing loads on the webpage. but if I remove this bit of code, it works fine: if ("" . $tnrow['newsimage'] . "" == "none") { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } else { $radio= "SELECT imageposition FROM newsimage"; if ($radio == 'Centre') { <p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Right') { <p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Left') { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } Can anyone see where I am going wrong? I have spent that long looking at it I just can't see where I am wrong!! Any help would be vastly appreciated!
  12. When i am using this in my code and run getuser.php file the i am getting a drop down, a default table and a notice that is Undefined index: q in C:\wamp\www\sample\getuser.php on line 43 and when i select any name from drop down then there is making one more same drop down,and a new table which is working properly. But Problem is that what about the previous dropdown, table and notice. <html> <head> <script type="text/javascript"> function showUser(str){ if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "getuser.php?q=" + str, true); xmlhttp.send(); } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="1">Peter Griffin</option> <option value="2">Lois Griffin</option> <option value="3">Glenn Quagmire</option> <option value="4">Joseph Swanson</option> </select> </form> <br/> <div id="txtHint"> <b>Person info will be listed here.</b> </div> </body> </html> <?php $q=$_GET["q"]; mysql_connect('localhost', 'root', ''); mysql_select_db("sample"); $sql="SELECT * FROM user WHERE id = '".$q."'"; $result = mysql_query($sql); echo "<table border='1'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close(); ?>
  13. I'm using a classified ads script that I want to modify. Although I have zero experience using PHP I've managed to link the classified script with my MYsql database, in addition to modifying the look of the site to the way I want. I'll explain the modification that I want: When you post an ad on my site I want the information to be listed vertically in the form of a box with the main information present within the box, not horizontally like a craiglist ad, which is how it looks right now. I want the next ad thats posted (also in a box) to be placed alongside, to the left of the previous ad, pushing it to the right. Its like choosing between list view or gallery view on ebay. I want the ads to be only viewed in a gallery mode. I want 5 columns/spaces for 5 boxes accross, and 10 rows down before the ad gets pushed to the next page. I hope this makes sense. How hard will it be to create a script that can do this? Do I need to know more than just PHP?
  14. Location: Vietnam - Full-time Responsibilities: Be responsible for developing, enhancing, administrating websites utilizing in depth PHP and MySQL skills Build and maintain the core PHP based applications & ecommerce module for the company ecommerce website Design, develop and maintain relational database systems and their web interfaces Be responsible for integrating MySQL database with the client websites, integrating ecommerce website with backend CRM and internal systems Develop web page infrastructure and application related to pages with more advanced graphics and features Assist the Operations Director in the planning of overall company strategy regarding web development and search engine optimization Monitor web server and site technical performance Skills / Attributes Required: Previous PHP programming experience (preferably on Unix/Linux environment) Strong database knowledge, specifically MySQL knowledge Wordpress’s, Vtiger’s customization experience is highly desirable A flexible attitude with proven experience of working in a small team Good English language skills are required Excellent communication skills and attention to detail If you are interested in this position,please send us your resume at career@kms-technology.com You can find here for more information : http://kms-technology.com/b/careers/
  15. I have a search class with pagination and I can get the first page to display correctly but the next page gives a bunch of undefined index(s). I know i need to pass the variables to the next page but it only uses one "View" and a "Class". I have tried to make all the $_POST variables into $_SESSIONS and that still did not work. Im sure if I could make the pagination stay at "Search" and not go to "Search?page=2" it might work, but I don't know how to do that exactly. Here is the Pagination and Search Function class/code: <?php class Search extends MainController{ function __construct(){ parent::__construct(); $this->view->url = $this->config->url; $this->view->ID = get_class($this); $this->view->Title = "Diablo 3 Online Auction House"; $this->view->msg = ""; $this->view->err = false; $itemName = isset($_POST['item_name']) ? $_POST['item_name'] : ''; $val_1 = $_POST['attrib1']; $val_2 = $_POST['attrib2']; $val_3 = $_POST['attrib3']; $val_4 = $_POST['attrib4']; $val_5 = $_POST['attrib5']; $val_6 = $_POST['attrib6']; $val_7 = $_POST['attrib7']; $val_8 = $_POST['attrib8']; $itemAttrib1 = $_POST['list_1']; $itemAttrib2 = $_POST['list_2']; $itemAttrib3 = $_POST['list_3']; $itemAttrib4 = $_POST['list_4']; $itemAttrib5 = $_POST['list_5']; $itemAttrib6 = $_POST['list_6']; $itemAttrib7 = $_POST['list_7']; $itemAttrib8 = $_POST['list_8']; $Quality = $_POST['quality']; $Type = $_POST['type']; $sub_Type = $_POST['sub']; $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; // If the page wasn't set, lets set $page to number 1 for the first page $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1) AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2) AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3) AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4) AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5) AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6) AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7) AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8))"; $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8); $ctr = $this->database->DBCtr($sql,$arr); $this->view->count = $ctr; // Lets set how many messages we want to display $per_page = "5"; // Now we must calculate the last page $last_page = ceil($ctr/$per_page); // And set the first page $first_page = "1"; // Here we are making the "First page" link if ($page == $first_page){ $this->view->first = "<li class='disabled'><a href='?page=".$first_page."'>First page</a></li>"; }else{ $this->view->first = "<li><a href='?page=".$first_page."'>First page</a></li>"; } // If page is 1 then remove link from "Previous" word if($page == $first_page){ $this->view->prev = "<li class='disabled'><a>Previous</a></li>"; }else{ if(!isset($page)){ $this->view->prev = "<li><a>Previous</a></li>"; }else{ // But if page is set and it's not 1.. Lets add link to previous word to take us back by one page $previous = $page-1; $this->view->prev = "<li><a href='?page=".$previous."'>Previous</a></li>"; } } // If the page is last page.. lets remove "Next" link if($page == $last_page){ $this->view->next = "<li class='disabled'><a>Next</a></li>"; }else{ // If page is not set or it is set and it's not the last page.. lets add link to this word so we can go to the next page if(!isset($page)){ $next = $first_page+1; $this->view->next = "<li><a href='?page=".$next."'>Next</a></li> "; }else{ $next = $page+1; $this->view->next = "<li><a href='?page=".$next."'>Next</a></li>"; } } // And now lets add the "Last page" link if ($page == $last_page){ $this->view->last = "<li class='disabled'><a href='?page=".$last_page."'>Last page</a></li>"; }else{ $this->view->last = "<li><a href='?page=".$last_page."'>Last page</a></li>"; } // Math.. It gets us the start number of message that will be displayed $start = (($page * $per_page) - $per_page); // Now lets set the limit for our query $limit = "LIMIT $start, $per_page"; $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1) AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2) AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3) AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4) AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5) AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6) AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7) AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8)) $limit"; $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8); $this->view->items = $this->database->DBQry($sql,$arr); $this->view->msg = "Successful Search"; $this->view->err = true; $this->view->render('Search/Index'); } } ?> here is the "Search/Index" View: <?php include_once("views/Header.php"); ?> <div class="container"> <?php if($this->err == true): ?> <div class="alert alert-success alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php else: ?> <div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php endif ?> <div class="well well-sm"> <div class="row col-xs-12"> <div class="btn-group"> <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown" href="#" style="font-weight: normal;"><?php if ($url == '/us/sc') { ?>US Softcore<?php }elseif ($url == '/us/hc') { ?> US Hardcore <?php } ?> <span class="caret"></span> </a> <ul class="dropdown-menu open" style="padding: 5px;"> <li><a href="<?php echo $ahurl; ?>/sc">US Softcore</a></li> <li class="divider"></li> <li><a href="<?php echo $ahurl;?>/hc">US Hardcore</a></li> </ul> </div> </div> </div> <?php include("models/ItemSearch.php"); ?> <div class="row"> <div class="col-md-8"> <!-- Item --> <?php $count = 0; if (count($this->items)%3!=0) { //Append 1 or 2 items from start of array if needed } ?><div class="row"> <?php foreach ($this->items as $item): if (($count>0) and ($count%3==0)): ?></div><div class="row"><?php endif; ?><div class='col-md-4'> <div class="thumbnail"> <h4 <?php if ($item['quality'] == 'Legendary'): ?> class="item-title quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-title quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-title quality-yellow" <?php endif ?>><a class="item-title" style="text-decoration:none;" href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"><?php echo $item['item_name']; ?></a></h4> <a href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"> <img <?php if ($item['quality'] == 'Legendary'): ?> class="item-icon quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-icon quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-icon quality-yellow" <?php endif ?> src="<?php echo $this->url.$item['item_img']; ?>" align="left" /></a> <div class="caption"> <?php if ($item['armor'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"><li class="armor"><?php echo $item['armor']; ?></li>Armor</ul> <?php }if ($item['dps'] == NULL && $item['min_max'] == NULL && $item['aps'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"> <li class="dmg"><?php echo $item['dps']; ?></li><li class="dps"> Damage Per Second</li> <li><?php echo $item['min_max']; ?> Damage</li> <li><?php echo $item['aps']; ?> Attacks Per Second</li> </ul> <?php }?> <div class="prop"> <ul class="item-attrib"> <?php if($item['attrib_1'] == 'None' || $item['attrib_1'] == '' || $item['attrib_1'] == 'none' || $item['attrib_1'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_1']; ?> <?php echo $item['attrib_1']; ?></li> <?php }if ($item['attrib_2'] == 'None' || $item['attrib_2'] == '' || $item['attrib_2'] == 'none' || $item['attrib_2'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_2']; ?> <?php echo $item['attrib_2']; ?></li> <?php }if ($item['attrib_3'] == 'None' || $item['attrib_3'] == '' || $item['attrib_3'] == 'none' || $item['attrib_3'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_3']; ?> <?php echo $item['attrib_3']; ?></li> <?php }if ($item['attrib_4'] == 'None' || $item['attrib_4'] == '' || $item['attrib_4'] == 'none' || $item['attrib_4'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_4']; ?> <?php echo $item['attrib_4']; ?></li> <?php }if ($item['attrib_5'] == 'None' || $item['attrib_5'] == '' || $item['attrib_5'] == 'none' || $item['attrib_5'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_5']; ?> <?php echo $item['attrib_5']; ?></li> <?php }if ($item['attrib_6'] == 'None' || $item['attrib_6'] == '' || $item['attrib_6'] == 'none' || $item['attrib_6'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_6']; ?> <?php echo $item['attrib_6']; ?></li> <?php }if ($item['attrib_7'] == 'None' || $item['attrib_7'] == '' || $item['attrib_7'] == 'none' || $item['attrib_7'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_7']; ?> <?php echo $item['attrib_7']; ?></li> <?php }if ($item['attrib_8'] == 'None' || $item['attrib_8'] == '' || $item['attrib_8'] == 'none' || $item['attrib_8'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_8']; ?> <?php echo $item['attrib_8']; ?></li> <?php }if ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php } ?> </ul> </div> </div> </div> </div><?php $count++; endforeach; ?> <!-- end item --> </div> </div> <ul class="pager"> <?php echo $this->first; echo $this->prev; echo $this->next; echo $this->count; echo $this->last; ?> </ul> </div> </div> </div> <?php include_once("views/Footer.php"); ?>
  16. Hello, there. I've been messing around with this stuff recently and ran across this error when trying to output a message when not all login fields are filled in, as well as an error when trying to output a successful login message.. These parts of the code are: Check all fields filled: //get the form data $myusername = ($_POST['username']); $mypassword = ($_POST['password']); //check if all fields are filled in if ( (!$myusername) || (!mypassword) ) ) { echo "Please fill in all fields"; exit; } Check if user exists & log in: //check if user exists if ($account ==1) { $_SESSION["username"] = $myusername; $_SESSION["password"] = $mypassword; $_SESSION["userrecord"] = mysql_fetch_assoc($result); echo "You have been logged in successfully. Please click <a href=account.php>here</a> to continue."; } As you can probably tell from the title, the echo does not output onto the webpage. Any help is very much appreciated. Thanks.
  17. hi Guys, just for a quick question summary: I want to add new data in my table however, i want to check if my new data name has same name with stored data name in table, if not same name we can proceed to adding new data/post. in my database table: ===================== ID | title | remarks 01 | orange | fruit 02 | mango | fruit addfile.php $newtitle = mysql_real_escape_string($_POST['title']); $newtitle = htmlentities($newtitle); $sqldbtitle = "SELECT * FROM tblmainfile WHERE strcmp('$newtitle','title') = 0 LIMIT 1; $getdbtitle = mysqli_query($con,$sqldbtitle); newfile.php; <form> <tr> <td>Title:</td> <td><input type="text" name="title" value="<?php echo $newtitle; ?>"></td> </tr> </form> goal: if i will add orange, it will notify me that there is already orange in table. questions: 1. will strcmp be faster or i will just use mysql query? thanks a lot!
  18. Hi I am writing this code for a wordpress plugin that gets content from a json file and then decodes them <table border="1"> <tr> <th>Thumbnail</th> <th>Title</th> <th>Excerpt</th> </tr> <?php $url = http://localhost/wordpress/json; $json = file_get_contents($url); $safe_json = str_replace("\n", "\\n", $json); $query = json_decode($json, true); foreach ( $query as $item ) { echo '<tr>'; echo '<td>' . $item['image'] .'</td>'; echo '<td>' . $item['title'] .'</td>'; echo '<td>' . $item['excerpt'] .'</td>'; echo '</tr>'; } ?> Now I need help in paginating the data. Any help will be appreciated.
  19. I have a dropdown menu created from javascript, so the onchange event should call a function called updateForBodyfittingoptions(). The thing here is that this function updateForBodyfittingoptions() should actually run dependent on a loop that is part of another function called UpdateDivision. So if I were to put the function UpdateBodyfitting directly within the loop of the other function updateSelectClothByDiv(division) then I get "Object Expected". Remember the onchange calls the UpdateBodyfitting function. Here is the code which I've shortened for purposes of posting on here, I've also attached the main php file with all the code just in case anyone wants to reference it. , the main function is "generateUpdateSelectClothByDiv", within this function are "updateForBodyfittingoptions" and "updateSelectClothByDiv(division)". Really appreciate any help I can get, thanks in advance. function generateUpdateSelectClothByDiv() { global $connect,$hriconnect,$division_array,$cloth_array,$lining_array,$lining_sleeve_array,$bodyfitting_array,$pantstyle_array,$veststyle_array,$glob_div; $indexdiv=1; $indexbody=1; //global $field1_array,$field2_array,$field4_array,$extras_array,$field5_array; // echo "\t\tdocument.pickDivision.bodyfitting.selectedIndex=-1;\n"; $cloth_numrows = 0; $clothArray = array(); $div_query = "SELECT distinct DIVISION, CLOTHDB FROM MTM_DIVISIONS_S ORDER BY CLOTHDB"; $div_result = oci_parse($connect,$div_query); oci_execute($div_result); while ($div_row = oci_fetch_array($div_result, OCI_ASSOC)) { $divArray[] = "{$div_row['CLOTHDB']}"; $divDivArray[] = "{$div_row['DIVISION']}"; } oci_free_statement($div_result); // print("//TEST\n\n"); echo "\tfunction updateSelectClothByDiv(division)\n"; echo "\t{\n"; $first = 0; echo "\tClearOptionsFastAlt('cloth');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; //echo "alert(divcomp)"; for ($i = 0; $i < sizeof($divArray); $i++) { $cloth_query="SELECT CLOTH, CODE FROM ".$divArray[$i]." where CODE <>'OUT' or CODE is null ORDER BY cloth"; $cloth_result = oci_parse($connect,$cloth_query); oci_execute($cloth_result); $cloth_numrows = count_rows($connect,$cloth_query); $maxclothrows=$cloth_numrows+1; $bodyfitting_query="SELECT BODYFITTING, BFCODE FROM MTM_STYLES_S WHERE DIVISION= '".$divDivArray[$i]."' AND STYLE_TYPE='BODY' GROUP BY BODYFITTING, BFCODE ORDER BY BODYFITTING"; $bodyfitting_result = oci_parse($connect,$bodyfitting_query); oci_execute($bodyfitting_result); $bodyfitting_numrows = count_rows($connect,$bodyfitting_query); $maxclothrows=$bodyfitting_numrows+1; if($first == 0) { $first++; } else { echo "\telse\t"; } //echo "\talert('$divArray[$i]' +' '+ '$divDivArray[$i]'+' :aaa:' + divcomp);"; echo "\tif (divcomp == \"{$divDivArray[$i]}\") {"; $y=1; echo "var selectObj = document.pickDivision.cloth;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Cloth -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($cloth_row = oci_fetch_array($cloth_result, OCI_ASSOC)) { $newCloth=$cloth_row['CODE']; $newStyle=$cloth_row['CLOTH']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newStyle.' '.$newCloth."', '".$newStyle."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.cloth.options[0].selected = true;\n\n"; echo "\tClearOptionsFastAlt('lining');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.lining;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Lining -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($lining_row = oci_fetch_array($lining_result, OCI_ASSOC)) { $newLining=$lining_row['CLOTH']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newLining."' ,'".$newLining."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.lining.options[0].selected = true;\n\n"; //Setup new dropdown for Style Selection echo "\tClearOptionsFastAlt('bodyfitting');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.bodyfitting;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Style -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($bodyfitting_row = oci_fetch_array($bodyfitting_result, OCI_ASSOC)) { $newBodyfitting=$bodyfitting_row['BODYFITTING']; $newBfcode=$bodyfitting_row['BFCODE']; $bodyfitArray[] = "{$bodyfitting_row['BFCODE']}"; $bodyfitbodyarray[]="{$bodyfitting_row['BODYFITTING']}"; echo "\t\t\tselectObj.options[numShown] = new Option('".$newBfcode.' '.$newBodyfitting."', '".$newBfcode."');\n"; echo "\t\t\tnumShown++;\n"; $y++; echo "\tfunction updateForBodyfittingoptions()\n"; echo "\t{\n"; echo "\t\tif(document.pickDivision.bodyfitting.options.value == '{$bodyfitting_row['BFCODE']} {$bodyfitting_row['BODYFITTING']}')\n"; echo "\t\t{\n"; //Show selection for front $field1_query = "SELECT MTM_STYLES_S.CODE,MTM_SUFFEX_S.TEXT FROM MTM_STYLES_S,MTM_SUFFEX_S WHERE MTM_SUFFEX_S.DIVISION='".$divDivArray[$i]."' AND (MTM_STYLES_S.FIELD=MTM_SUFFEX_S.FIELD AND MTM_STYLES_S.CODE=MTM_SUFFEX_S.CODE) AND MTM_STYLES_S.STYLE_TYPE='BODY' AND MTM_STYLES_S.BODYFITTING='".$bodyfitting_row['BODYFITTING']."' AND MTM_STYLES_S.FIELD=1 ORDER BY MTM_STYLES_S.FIELD,MTM_STYLES_S.CODE"; $field1_result = oci_parse($connect,$field1_query); oci_execute($field1_result); echo "\t\t\tdocument.pickDivision.field1.options[0].value = '';\n"; echo "\t\t\tdocument.pickDivision.field1.options[0].text = '- Select Frontaaa';\n\n"; $y=1; while ($field1_row = oci_fetch_array($field1_result, OCI_ASSOC)) { $newField1=$field1_row['TEXT']; $newField1Code=$field1_row['CODE']; $bodyfitArray[] = "{$bodyfitting_row['BFCODE']}"; $bodyfitbodyarray[]="{$bodyfitting_row['BODYFITTING']}"; echo "\t\t\tselectObj.options[numShown] = new Option('".$newField1Code.' '.$newField1."', '".$newField1Code."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.field1.options[0].selected=true;\n\n"; $indexfield1=1; oci_free_statement($field1_result); echo "\t\t}\n\n"; echo "\t\t}\n\n"; } echo "\t\t\tdocument.pickDivision.bodyfitting.options[0].selected=true;\n\n"; echo "\t}\n\n"; oci_free_statement($bodyfitting_result); $indexbody=1; oci_free_statement($cloth_result); } $indexdiv++; echo "\t\treturn true;\n"; echo "\t}\n\n"; oci_close($connect); } mtm.php
  20. I need help with performance improvement of this script. Script is working fine, but it's quite slow. It loads a lot of data, around 200.000. I am using paging to speed it up, but it's still slow. Can you give me any guide lines how to speed it up or to optimize? //Početak paginga if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if $upit11 = mysql_query("SELECT id FROM kalkulacija_stavke WHERE id_kalkulacija = '$id_kalkulacije' AND kataloski_broj NOT LIKE '1%'") or die (mysql_error()); $brojcanik = mysql_num_rows($upit11); $rows_per_page = 100; $lastpage = ceil($brojcanik/$rows_per_page); $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; mysql_query( "SET NAMES utf8", $veza ); mysql_query( "SET CHARACTER SET utf8", $veza ); if($_SESSION["checked"] = "checked"){ $upit = "SELECT kalkulacija_stavke.*, kalkulacija_zamjene_staro.ne_koristi_se FROM kalkulacija_stavke LEFT JOIN kalkulacija_zamjene_staro ON kalkulacija_stavke.kataloski_broj = kalkulacija_zamjene_staro.kataloski_broj_stari WHERE id_kalkulacija = '$id_kalkulacije' AND ne_koristi_se = '0' AND kataloski_broj NOT LIKE '1%' ORDER BY kataloski_broj ASC $limit"; } else { $upit = "SELECT * FROM kalkulacija_stavke WHERE id_kalkulacija = '$id_kalkulacije' AND kataloski_broj NOT LIKE '1%' ORDER BY kataloski_broj ASC $limit"; } $rezultat = mysql_query($upit,$veza) or die (mysql_error()); while($row = mysql_fetch_array($rezultat)){ $broj = $row["id"]; $id_kalk = $row["id_kalkulacija"]; $id_cjen = $row["id_cjenika"]; $vrijeme = $row["vrijeme"]; $kataloski_broj = trim($row["kataloski_broj"]); $kategorija_artikla = $row["kategorija_artikla"]; $grupa_proizvoda = $row["grupa_proizvoda"]; $podgrupa_proizvoda = $row["podgrupa_proizvoda"]; $cijena_eurska = number_format(round(($row["cijena_EUR"]),2),2,",","."); $cijena_KN = number_format(round(($row["cijena_KN"]),2),2,",","."); $carina = number_format(round(($row["carina"]),2),2,",","."); $spediter = number_format(round(($row["spediter"]),2),2,",","."); $banka = number_format(round(($row["banka"]),2),2,",","."); $transport = number_format(round(($row["transport"]),2),2,",","."); $nabavna_cijena = number_format(round(($row["nabavna_cijena"]),2),2,",","."); $drezga_marza_po_grupi = number_format(round(($row["drezga_marza_po_grupi"]),2),2,",","."); $drezga_zarada = number_format(round(($row["drezga_zarada"]),2),2,",","."); $neto_VPC = number_format(round(($row["neto_VPC"]),2),2,",","."); $neto_MPC = number_format(round(($row["neto_MPC"]),2),2,",","."); $trosak_firme = number_format(round(($row["trosak_firme"]),2),2,",","."); $trosak_firme_p = number_format(round(($row["trosak_firme_p"]),2),2,",","."); $diler_marza_po_grupi = number_format(round(($row["diler_marza_po_grupi"]),2),2,",","."); $preporucena_VPC = number_format(round(($row["preporucena_VPC"]),2),2,",","."); $preporucena_MPC = number_format(round(($row["preporucena_MPC"]),2),2,",","."); $zarada_diler_kn = number_format(round(($row["zarada_diler_kn"]),2),2,",","."); $zarada_diler_p = number_format(round(($row["zarada_diler_post"]),2),2,",","."); $zarada_za_nas_kn = number_format(round(($row["zarada_za_nas_kn"]),2),2,",","."); $zarada_za_nas_p = number_format(round(($row["zarada_za_nas_post"]),2),2,",","."); $brutto_zarada_za_nas_kn = number_format(round(($row["brutto_zarada_za_nas_kn"]),2),2,",","."); $brutto_zarada_za_nas_p = number_format(round(($row["brutto_zarada_za_nas_post"]),2),2,",","."); $datum1 = date("d.m.Y H:i:s",strtotime($vrijeme)); //Dohvačanje starih i zamjenjenih brojeva $upit23 = "SELECT ne_koristi_se, kataloski_broj_novi FROM kalkulacija_zamjene_staro WHERE kataloski_broj_stari = '$kataloski_broj'"; $query23 = mysql_query($upit23) or die (mysql_error()); $row = mysql_fetch_array($query23); $staro = $row["ne_koristi_se"]; $zamjena_novo = $row["kataloski_broj_novi"]; echo ' <tr> <td width="65"> '; if (!empty($zamjena_novo)){ echo '<img src="images/zamjena.png" border="0" title="Broj je zamijenjen sa '.$zamjena_novo.'">'; } if (!empty($staro) AND $staro == 1){ echo ' <img src="images/staro.png" border="0" title="Broj se ne koristi!">'; } //Dohvačanje naziva artikla iz NAV-a $upit233 = "SELECT naziv_artikla FROM kalkulacija_import_kategorija WHERE kat_br = '$kataloski_broj'"; $query233 = mysql_query($upit233) or die (mysql_error()); $row = mysql_fetch_array($query233); $naziv_artikla = $row["naziv_artikla"]; if (empty($naziv_artikla)) { $upit234 = "SELECT naziv FROM kalkulacija_import_cjenik_stavke WHERE kataloski_broj = '$kataloski_broj'"; $query234 = mysql_query($upit234) or die (mysql_error()); $row44 = mysql_fetch_array($query234); $naziv_artikla = $row44["naziv"]; } //Zamjena hrvatskih znakova $some_special_chars = array("æ", "è", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ"); $replacement_chars = array("ć", "č", "i", "o", "u", "A", "Ć", "I", "O", "U", "n", "N"); $replaced_string = str_replace($some_special_chars, $replacement_chars, $naziv_artikla); echo' </td> <td width="120"><span title="VPC: '.$neto_VPC.' - PVPC: '.$preporucena_VPC.'">'.$kataloski_broj.'</span></td> <td width="200">'.$replaced_string.'</td> <td width="100"><div align="center">'.$kategorija_artikla.'</div></td> <td width="110"><div align="center">'.$grupa_proizvoda.'</div></td> <td width="140"><div align="center">'.$podgrupa_proizvoda.'</div></td> <td width="110"><div align="center">'.$cijena_eurska.'</div></td> <td width="90"><div align="center">'.$cijena_KN.'</div></td> <td width="80"><div align="center">'.$carina.'</div></td> <td width="80"><div align="center">'.$spediter.'</div></td> <td width="100"><div align="center">'.$banka.'</div></td> <td width="80"><div align="center">'.$transport.'</div></td> <td width="100"><div align="center">'.$nabavna_cijena.'</div></td> <td width="80"><div align="center">'.$drezga_marza_po_grupi.' %</div></td> <td width="100"><div align="center">'.$drezga_zarada.'</div></td> <td width="90"><div align="center"><strong>'.$neto_VPC.'</strong></div></td> <td width="90"><div align="center"><strong>'.$neto_MPC.'</strong></div></td> <td width="90"><div align="center">'.$diler_marza_po_grupi.' %</div></td> <td width="100"><div align="center">'.$zarada_diler_kn.'</div></td> <td width="110"><div align="center"><strong>'.$preporucena_VPC.'</strong></div></td> <td width="110"><div align="center"><strong>'.$preporucena_MPC.'</strong></div></td> <td width="90"><div align="center">'.$brutto_zarada_za_nas_kn.'</div></td> <td width="90"><div align="center">'.$brutto_zarada_za_nas_p.'</div></td> <td width="80"><div align="center">'.$trosak_firme_p.' %</div></td> <td width="80"><div align="center">'.$trosak_firme.'</div></td> <td width="100"><div align="center">'.$zarada_za_nas_kn.'</div></td> <td width="80"><div align="center">'.$zarada_za_nas_p.'</div></td> <td width="150"><div align="center"> '; if ($status == 1) { echo '<a href="povjest_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/povjest.png" border="0" width="20" height="20" alt="Povijest" title="Pogledaj povjest artikla"></a> <a href="usporedba_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/history1.png" border="0" alt="Usporedba" title="Usporedba retka sa prošlom godinom" width="25" heigth="25"></a> <a href="calculator.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'" onclick="basicPopup(this.href);return false"><img src="images/calculator_n.png" border="0" title="Kalkulator zarade za dilera"></a></div></td>'; } else { echo'<a href="izmjeni_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&id_cjenika='.$id_cjen.'"><img src="images/izmjeni.png" border="0" alt="Izmjeni" title="Izmjeni redak kalkulacije"></a> <a href="obrisi_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&id_cjenika='.$id_cjen.'" onclick="provjera(this.href); return false;"><img src="../brisanje.png" border="0" alt="Obrisi" title="Obriši redak kalkulacije"></a> <a href="povjest_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/povjest.png" border="0" width="20" height="20" alt="Povijest" title="Pogledaj povjest artikla"></a> <a href="usporedba_redak_kalkulacije.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'&kataloski_broj='.$kataloski_broj.'&id_cjenika='.$id_cjen.'"><img src="images/history1.png" border="0" alt="Usporedba" title="Usporedba retka sa prošlom godinom" width="25" heigth="25"></a> <a href="calculator.php?id='.$broj.'&id_kalkulacije='.$id_kalkulacije.'" onclick="basicPopup(this.href);return false"><img src="images/calculator_n.png" border="0" title="Kalkulator zarade za dilera"></a></div></td> </tr> '; } } echo ' </table> <p align="center"> </p> <p align="center"> '; if ($pageno == 1) { echo " <font color='#990000'>Početak</font> || Natrag "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1&id=$id_kalkulacije'>Prva</a> | "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage&id=$id_kalkulacije'>Natrag</a> "; } // if echo " ( <font color='grey'>Stranica - <b>$pageno</b> od <b>$lastpage</b></font> ) "; if ($pageno == $lastpage) { echo " Naprijed || <font color='#990000'>Kraj</font> "; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage&id=$id_kalkulacije'>Naprijed</a> | "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage&id=$id_kalkulacije'>Posljednja</a> "; } // if echo " <br />Rezultata: ".$brojcanik." </p>";
  21. I've been looking at this for a bit and can't seem to figure what's going on? I have used this code before and never had this issue.... I'm tryig to populate a dropdown menu from a MySql DB. The dropdown menu seems to skip the first array... I attached a screenshot that hopefully show's what I'm talking about.. any thoughts?
  22. How do companies such as vBulletin and WoltLab manage licenses given to users for the software they've bought? In other words, how do they know you've actually bought a license for the software and distinguish between "nulled" and "legit" software (that is, forums)? Obviously they do it somehow, otherwise the business model of distributing PHP-based forum software wouldn't bring in any revenue. Does it have to do with PHP, and can you implement a certain check within the software that communicates back to the licenser?
  23. I am trying to execute git commands through exec() in php file. The php file is run in my localhost and i am trying to mainly execute these three commands:- cd change_to_git_directory git add * git commit -m hfwejfk git push but these commands are not getting executed as no changes are there in my git repository. So, what to do?
  24. I have not seen any examples that show how to return the value for the last Identity that was last generated, how do i get the last generated ID. I need example for calling stored procedures? The current INSERT a Record into the database but doesn't retrieve the ID that Generated. Sample SQL ran from work bench, record is created SET @Id := 0; call uspIns_ExcelExport(@Id, 'Admin', 'Filename', 0,0,null,''); SELECT LAST_INSERT_ID(); Table delimiter $$ CREATE TABLE `excelexport` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `userId` varchar(100) DEFAULT NULL, `filename` varchar(256) DEFAULT NULL, `success` bit(1) DEFAULT NULL, `started` bit(1) DEFAULT NULL, `finished` datetime DEFAULT NULL, `error` varchar(2000) DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8$$ Store Procedure: DELIMITER $$ /**** INSERT Stored Procedures ****/ CREATE PROCEDURE `uspIns_ExcelExport`( OUT OUT_Id BIGINT, IN IN_userId VARCHAR(100), IN IN_filename NVARCHAR(256), IN IN_success INT, IN IN_started INT, IN IN_finished DATETIME, IN IN_error NVARCHAR(2000)) BEGIN INSERT INTO `ExcelExport` (`userId`, `filename`, `success`, `started`, `finished`, `error`) VALUES (IN_userId, IN_filename, IN_success, IN_started, IN_finished, IN_error); SELECT * FROM `ExcelExport` WHERE `Id` = LAST_INSERT_ID(); END$$ PHP MySQL Code public function Create() { $returnValue = false; if (isset($this->userId)) { $mysqli = new mysqli(__MYSQL_HOST__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__, __MYSQL_DBNAME__); if (!$mysqli->connect_errno){ $Id = -1; $stmt = $mysqli->prepare("call uspIns_ExcelExport (?,?,?,?,?,?,?)"); if ( !$stmt ) { die('mysqli error: '.$mysqli->errno); } if (!$stmt->bind_param('issiiss', $Id, $this->userId, $this->filename, intval($this->success), intval($this->started), $this->finished, $this->error)){ die( 'stmt error: '.$stmt->errno ); } if (!$stmt->execute()){ die( 'stmt error: '.$stmt->errno ); } $rtnId = 0; $stmt->store_result(); $stmt->bind_result($rtnId); while ($stmt->fetch()){ printf ("%s\n", $rtnId); } $stmt->free_result(); $stmt->close(); // $this->Id = $stmt->insert_id; } else{ echo "Failed to connect to MySQL: " . mysqli_connect_error(); } /* close connection */ mysqli_close($cn); if ($this->Id > 0) $this->exist = true; if ($this->Id > 0) $returnValue = true; } return $returnValue; }
  25. I'm having a problem with PHP and a stored procedure in SQL Server 2005. I haven't really touched stored procedures before and haven't used them with php. I can't retrieve a value from a table that I know is definitely there. I have a simple login table, what I want the stored procedure to do is to take a username as an input and then output that user's password salt. I want the stored procedure to use parameterised values to avoid SQL injection. What happens at the moment is when the php page is run, nothing is returned and the SQL Profiler displays the following error: User Error Message: Incorrect Syntax near '@Username' While this error message should tell me something is wrong, I can't for the life of me see where the incorrect syntax is. Copy of the Php: $user = "usercm"; $password ="cmuserpassword"; try{$conn = new PDO("odbc:DRIVER={SQL Server Native Client 10.0};SERVER=TestingServer;DATABASE=TestingDatebase;",$user,$password);} catch(PDOException $e){echo "oh no";} $username = "sdct"; $prepusp = $conn->prepare("EXEC uspReturnSalt(?,?)"); $prepusp->bindParam(1, $username, PDO::PARAM_STR); $prepusp->bindParam(2, $usersalt, PDO::PARAM_STR, 450); $prepusp->execute(); Copy of the Stored Procedure: ALTER PROCEDURE [dbo].[uspReturnSalt] @Username NVARCHAR(100), @Usersalt NVARCHAR(450) OUTPUT AS BEGIN DECLARE @sqlcmd NVARCHAR(MAX); DECLARE @params NVARCHAR(MAX); SET @sqlcmd = N'SELECT @Usersaltone = salt FROM CMUsers WHERE username = @Usernameone'; SET @params = N'@Usernameone NVARCHAR(100), @Usersaltone NVARCHAR(450) OUTPUT'; EXECUTE sp_executesql @sqlcmd, @params, @Usernameone = @Username, @Usersaltone = @Usersalt OUTPUT; END To clarify, the server this is on runs Windows 2003 so I cannot use the sqlsrv drivers as they require SQL Server Native Client 2012 which is incompatible. It is impossible to upgrade the operating system (server isn't mine) so I can't use any php drivers that require SQL Server Native Client 2012. If anyone could help I would be eternally grateful. Here is the sql profiler messages before and after that error: RPC:Completed | exec [sys].sp_sproc_columns_90 N'uspReturnSalt' ,@ODBCVer=3 RPC:Starting | declare @p1 int set @p1 =NULL exec sp_prepare @p1 output,N'@Username nvarchar(100),@P2 text OUTPUT' ,N'EXEC uspReturnSalt(@Username,@P2 OUTPUT)' ,1 select @p1 Exception | Error: 102, Severity: 15, State: 1 User Error Message | Incorrect syntax near '@Username'. SP:CacheMiss | (@Username nvarchar(100),@P2 text OUTPUT)EXEC uspReturnSalt(@Username,@P2 OUTPUT) Exception | Error: 8180, Severity: 16, State: 1 User Error Message | Statement(s) could not be prepared RPC:Completed | declare @p1 int set @p1=NULL exec sp_prepare @p1 output, N'@Username nvarchar(100),@P2 text OUTPUT' ,N'EXEC uspReturnSalt(@Username,@P2 OUTPUT)',1 select @p1
×
×
  • Create New...

Important Information

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