Jump to content

ethan6

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Posts posted by ethan6

  1. When I try to run this code:

    <?
    session_start();
    
    $username = "user";
    $password = "pass";
    $hostname = "localhost";
    $database = "database";
    $con = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to database.");
    mysql_select_db($database, $con) 
    or die("Could not select itroni5_cart");
    
    $answer_a = mysql_real_escape_string($_POST['wysiwyg'],$con);
    $answer = nl2br($answer_a);
    
    $query="INSERT INTO answers (idquestion, username, answer) VALUES ('".$_POST['idquestion']."','".$_SESSION['username']."', '".$answer."')";
    $result=mysql_query($query) or die(mysql_error());
    
    header("Location: answers.php");
    ?>

     

    I get this error:

     

     

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'user'@'localhost' (using password: NO) in /home/itroni5/public_html/testwysiwyg.php on line 4

     

    Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/itroni5/public_html/testwysiwyg.php on line 4

     

     

    any ideas? Thanks!

  2. Hello, I have a simple shopping cart in php and I have it set that when the user wants, they can click checkout and it brings them to paypal to pay.

     

    Unfortunately, I can't seem to get all the variables to output in the "items" line, i can only get the last item in the cart (I think it's like in an array?)

     

    Here's the code of the function showCart() that has the button to click on to go to paypal at the bottom:

    function showCart() {
    global $db;
    $cart = $_SESSION['cart'];
    if ($cart) {
    	$items = explode(',',$cart);
    	$contents = array();
    	foreach ($items as $item) {
    		$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
    	}
    	$output[] = '<form action="cart.php?action=update" method="post" id="cart">';
    	$output[] = '<table>';
    	foreach ($contents as $id=>$qty) {
    		$sql = 'SELECT * FROM parts WHERE id = '.$id;
    		$result = $db->query($sql);
    		$row = $result->fetch();
    		extract($row);
    		$output[] = '<tr>';
    		$output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>';
    		$output[] = '<td>'.$part.'</td>';
    		$output[] = '<td>&#36;'.$price.'</td>';
    		$output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';
    		$output[] = '<td>&#36;'.($price * $qty).'</td>';
    		$total += $price * $qty;
    		$output[] = '</tr>';
    	}
    	$output[] = '</table>';
    	$output[] = '<p>Grand total: <strong>&#36;'.$total.'</strong></p>';
    	$output[] = '<div><button type="submit">Update cart</button></div>';
    	$output[] = '</form><br>';
    	$output[] = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    	$output[] = '<input type="hidden" name="cmd" value="_xclick">';
    	$output[] = '<input type="hidden" name="business" value="Service@iTronicsRepair.com">';
    	$output[] = '<input type="hidden" name="item_name" value="'.$part.'">';
    	$output[] = '<input type="hidden" name="item_number" value="'.$id.'">';
    	$output[] = '<input type="hidden" name="amount" value="'.$total.'">';
    	$output[] = '<input type="hidden" name="shipping" value="2.99">';
    	$output[] = '<input type="hidden" name="no_shipping" value="2">';
    	$output[] = '<input type="hidden" name="return" value="http://itronicsrepair.com/thankyou_order.php">';
    	$output[] = '<input type="hidden" name="cancel_return" value="http://itronicsrepair.com/cancel_order.php">';
    	$output[] = '<input type="hidden" name="currency_code" value="USD">';
    	$output[] = '<input type="hidden" name="tax" value="0.00">';
    	$output[] = '<input type="hidden" name="lc" value="US">';
    	$output[] = '<input type="hidden" name="bn" value="PP-BuyNowBF">';
    	$output[] = '<input type="image" src="http://itronicsrepair.com/img/checkout.jpg" border="0" name="submit" alt="Make payments with PayPal - it is fast, free and secure!">';
    	$output[] = '<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">';
    	$output[] = '</form>';
    } else {
    	$output[] = '<p>You shopping cart is empty.</p>';
    }
    return join('',$output);
    }
    ?>

     

    It is this line above where I want to output every part id#, not just the last one in the list:

    		$output[] = '<input type="hidden" name="item_name" value="'.$part.'">';
    

     

    Any thoughts? thanks.

     

    oh if you want to view the cart, it is at http://itronicsrepiar.com/parts.php .. put something in the cart and then it brings you to http://itronicsrepair.com/cart.php

     

    thanks.

     

  3. I dont think your understanding me! I dont want to learn it, i want a tutorial (script) for user profile.

     

    it's not something you can just copy and paste.. it's a more complicated process and i'd suggest learning whatever you decide to use.

     

    Here's an outline of what you'll need to know:

    registration page:

    -create database (probably in PHP MyAdmin or similar)

    -create table for users in SQL

    -connect to database on page

    -PHP registration script on page that creates a new row in table "users"

     

    profile page:

    -connect to database

    -display user's data (accessing it from table in database)

    -use an html <form> to input data-- and then use PHP/SQL to Insert/Update this data in database

    -re-display updated data.

     

    Search google if you want a more in depth tutorial, but you're going to have to learn some PHP and SQL for this to work.

  4. Dont make any difference what so ever.

     

    I dont know if you know but is there a code where you can login (which i have) and then when you logged in you can create and edit a profile?

     

    ok so are you pasting that include code, editing the name of your file location, and it's not showing anything at all? also, is the file that you're putting it into a php file (ie. ends in .php)?

     

    creating profiles etc can become complicated, what you will probably need to learn is SQL if you haven't already.  In order to "create a profile, edit, update" etc, you will need a DATABASE.  Then using PHP, you will have the user access the database to update his/her information, and then it will save the changes on your server.  without this kind of database, it's impossible to store the user's information so he/she can come back to it later.

  5. Yeah, do you know how to embed for example into a HTML document, because the register and login is PHP...do you know how to add the code into a HTML file from a PHP file?

     

    well, i'm pretty sure you would need to switch your site over php (ie. index.php not index.html if that's what you have).

    once you do that, you can just "include" the login page right in the html like this.

    ...first part of html site here...
    <?php include("register_page.php"); ?>
    ..rest of html here...

     

  6. ok, imo the first thing i noticed is that the logo is WAY too tall.. you could do with 100 or 150 px just fine, it takes up way to much of my screen, and i lose out seeing more info on the site.

     

    i do like the "feel" of the site, very modern.

     

    note: Extras doesn't have an apostrophe (not "Extra's").

     

    i'd also agree that you should just have links that say "Register" or "Login" instead of the "Why not register with us?" or what you have.

×
×
  • 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.