Jump to content

xgd

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xgd's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello, I am making a shopping cart, and basically i got stuck. I do not know how to pass the value of the $total variable (which contains the order total) from view_cart.php to the checkout.php page so i can store it in a database. Can someone please help me with that ? I get the $total like this: $subtotal = $_SESSION['cart'][$row['print_id']]['quantity'] * $_SESSION['cart'][$row['print_id']]['price']; $total += $subtotal; So how do i know pass that $total variable to another page (in this case checkout.php) so i can freely use it ? thanks
  2. xgd

    mysqli error

    thanks dathremar, that helped, though there are still issues with the app, but i think it's too complicated to discuss here.
  3. xgd

    mysqli error

    The mysql syntax is for mysqli 4.0 or 4.1 i think, that's what the book uses, so it needs some modification for mysql 5 i believe. p.s. it does have type_id
  4. xgd

    mysqli error

    hello, I get this: Unknown column 'a.type_id' in 'on clause'
  5. Hello, I am getting the following error when i try to run some script: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given The script is a bit longish, so here's the part that matters (hopefully): case "content": #110 $dept_id = $_GET['dept_id']; $type_id = $_GET['type_id']; $sql = "SELECT a.name, a.type_id, b.title, b.description, b.content_date, b.create_date, b.created_by, b.last_upd_date, b.last_upd_by, c.name as dept_name, content_id FROM Content_Type a, Department c LEFT OUTER JOIN Content b on a.type_id = b.content_type and a.type_id = b.content_type and b.dept_id = $dept_id and b.content_type = $type_id WHERE c.dept_id = $dept_id ORDER BY content_date DESC"; $results = mysqli_query($cxn, $sql); $body_links = ""; $content_count = 0; $page["body_text"] = ""; while($row = mysqli_fetch_assoc($results)) #132 { if (!isset($area_name) && $type_id == $row["type_id"]) { I think it's something to do with the joints, and i personally don't know a thing about them (if that's the problem). I am usng Mysql version 5 something. thanks
  6. Hey man, i tried editing it like this : <?php if (mysqli_num_rows($ans5) == 0) { echo "No votes yet"; } else { while ($ans6 = mysqli_fetch_array($ans5)) { if ($total > 0) { $imagewidth = (100*$ans6['votes']) / $total; $imagewidth = round($imagewidth); print "$ans6[answer]($imagewidth%)<br>"; } } } ?> but now it doesn't show display "no votes yet" at all. what should i do ? thanks
  7. Helo, I am trying to write this voting poll script, and it works fine so far, but i have this small problem: if i click to view results, and there haven't been any votes cast, then it repetas "no votes yet" as many times as there are choices. currently i have 4 choices and so it prints the message 4 times instead of just once. Why does that happen ? Here's the script: <!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 require_once('connect.php'); $totalvotes = 0; $ans = "SELECT *FROM P_choices"; $ans2 = mysqli_query($dbc, $ans) or die ("couldnt select from choices"); while ($ans3 = mysqli_fetch_array($ans2)) { @$total = $total + $ans3['votes']; } // now display results echo "total votes $total<br />"; $ans4 = "SELECT * FROM P_choices"; $ans5 = mysqli_query($dbc, $ans4) or die ("couldnt select chooiuces 2"); while ($ans6 = mysqli_fetch_array($ans5)) { if ($total > 0) { $imagewidth = (100*$ans6['votes']) / $total; $imagewidth = round($imagewidth); print "$ans6[answer]($imagewidth%)<br>"; } else { echo "No votes yet<br />";// it repeats this 4 times because there are 4 choices } } ?> </body> </html>
  8. YEA IT WORKS! But the original problem wasnt the short tag, because all scripts from this guy are like that an others worked. I changed the connect.php to use mysqli instead of mysql (the code currently is pretty old) to this: $dbc = mysqli_connect("localhost", "voja", "kova", "content"); if (!$dbc) { echo "bla bla"; } and also i changed the mysql queries in install to be: $r = mysqli_connect($dbc, $inserttable(or hatever the var was) etc. Thanks for letting me know about the short php tag problem, but all in all iwill have to change ALL Tthe queries in all the scripts of the application to get it working (bummer). At least it will work (hopefully);
  9. Also if someone is bothered to check out this little app on his own and see what the issue is, pm me your email so i can send it to you, its only 15kb.
  10. Hello people. Ok i get this error when i run the install.php: Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\EasyPHP 3.0\www\install.php on line 9 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\Program Files\EasyPHP 3.0\www\install.php on line 9 Could not install tables I mean this is ridiculous. I few times i thought PHP was playing tricks on me when i wrote some scripts, but then i found that i had actually made a sily mistake somewhere, but this time it is beyond me. It simply doesnt get the username and password i put in the connect.php, and other scripts from this site work, but this one that is important does not!(go figure). So if i can get it working it would be really good. Oh yeah, but if i go straight to localhost/connect.php, it DOESNT DISPLAY ANYTHING, which basically means that it got connected to the db and selected it, otherwise it wouldve said "no db" and "n odatabase selected". What the hell is going on ?
  11. Hello, I am trying out some scripts and basically when i change the database settings, the script doesnt seem to recognize it so i get an error saying that access is deined for a user and a password that is not even in the file (connect.hp). Why does that happen ? I tried other scripts from the same site and it worked fine. Here is the dodgy script: connect.php <? $db = mysql_connect("localhost", "voja", "kova") or die("Could not connect."); if(!$db) die("no db"); if(!mysql_select_db("cms",$db)) die("No database selected."); ?> and install.php <?php include "connect.php"; $installiptable="CREATE TABLE `CMS_IP` ( `ID` bigint(20) NOT NULL auto_increment, `IP` varchar(60) NOT NULL default '', `EntryID` bigint(20) NOT NULL default '0', PRIMARY KEY (`ID`) )"; mysql_query($installiptable) or die("Could not install tables"); $installarticles="CREATE TABLE `CMS_articles` ( `EntryID` bigint(21) NOT NULL auto_increment, `title` varchar(60) NOT NULL default '', `body` longtext NOT NULL, `shortdescription` mediumtext NOT NULL, `totalscore` decimal(20,0) NOT NULL default '0', `numvotes` bigint(20) NOT NULL default '0', `timesviewed` bigint(20) NOT NULL default '0', `CMS_tsubmit` varchar(255) NOT NULL default '', `CMS_telapsed` bigint(21) NOT NULL default '0', `CMS_author` varchar(255) NOT NULL default '', `avgvotes` float NOT NULL default '0', PRIMARY KEY (`EntryID`) )"; mysql_query($installarticles) or die("Could not install articles"); $installadmin=" CREATE TABLE `CMS_logintable` ( `id` int(5) unsigned NOT NULL auto_increment, `username` varchar(32) default NULL, `password` varchar(32) default NULL, PRIMARY KEY (`id`) )"; mysql_query($installadmin) or die("Could not install admin"); print "Everything is installed, please delete this file."; ?> and the script that works for example is this: connect.php <?php $db = mysql_connect("localhost", "voja", "kova") or die("Could not connect."); if(!$db) die("no db"); if(!mysql_select_db("cms",$db)) die("No database selected."); ?> and install.php <?php include "admin/connect.php"; $sql="CREATE TABLE P_question ( ID int(21) NOT NULL auto_increment, question varchar(100) NOT NULL default '', PRIMARY KEY (ID) )"; mysql_query($sql) or die("Questions not installed"); $sql2="CREATE TABLE P_ip ( ID bigint(21) NOT NULL auto_increment, IP varchar(40) NOT NULL default '', PRIMARY KEY (ID) ) "; mysql_query($sql2) or die("Table not installed"); $sql3="CREATE TABLE P_choices ( ID int(10) NOT NULL auto_increment, answer varchar(100) NOT NULL default '', votes bigint(21) NOT NULL default '0', PRIMARY KEY (ID) )"; mysql_query($sql3) or die("choices not installed"); $sql4="CREATE TABLE P_admin ( ID int(10) NOT NULL auto_increment, username varchar(15) NOT NULL default '', password varchar(255) NOT NULL default '', PRIMARY KEY (ID) )"; mysql_query($sql4) or die("Admin not installed"); print "Poll Installed"; ?> I even tried using the same databse as you can see but something is wrong with the firt example, it simply for some reason wont recognize the username and password. What do you think is the problem?
  12. `Hello people, i am trying to get an example from this book i got working, but i get an error while creating the table WROX_SHOP_INVENTORY this is the code for the 2 tables: DROP TABLE IF EXISTS WROX_SHOP_INVENTORY; DROP TABLE IF EXISTS WROX_SHOP_CATEGORY; CREATE TABLE WROX_SHOP_CATEGORY ( CATEGORY_ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, CATEGORY_NAME VARCHAR(100) NOT NULL, PRIMARY KEY (CATEGORY_ID) ) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs; CREATE TABLE WROX_SHOP_INVENTORY ( ITEM_ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, ITEM_NAME VARCHAR(100) NOT NULL, ITEM_DESCRIPTION TEXT DEFAULT '', PRICE DOUBLE(5,2) NOT NULL, ITEM_IMAGE VARCHAR(255) DEFAULT 'img/none.gif', CATEGORY_ID INTEGER UNSIGNED NOT NULL, PRIMARY KEY (ITEM_ID), FOREIGN KEY (CATEGORY_ID) REFERENCES WROX_SHOP_CATEGORY(CATEGORY_ID) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs AUTO_INCREMENT=0; the error i get is: #1101 - BLOB/TEXT column 'ITEM_DESCRIPTION' can't have a default value Does anyone know what the problem is, because i am guessing it should be working since it is for mysql 5 and i have an up to date mysql. Thanks
  13. Mattal999. i am not sure if what you posted worked. I did it differently later and now the remember me feature works, but i also had to change the way i check if a user logged in.
  14. well to me it says line 149, but i have the w3 validation before the php code which i didnt post. Basically the error is on the line after the closing </html> tag. I think it might be missing a curly bracket or something like that but i cant figure it out. Sorry for the lack of information, it is a 5 script app.
×
×
  • 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.