Jump to content

Search the Community

Showing results for tags 'mysqli'.

  • 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. Hey, guys, I'm new in the whole php thing. I believe what I am asking here is super simple to do, I just wasn't able to find it anywhere. In the code below, you guys will notice that not all the fields show in every change of the dropdown menu TYPE, and, of course they don't, that's the whole point. I mean, I have arranged for each TYPE to have it's own fields. The thing is: how can I adapt for the html ECHO code to show ONLY the "labels", I mean, the pieces of HTML in the while($row = mysqli_fetch_array($result)), for the fields that were filled in? I mean, I don't want that in RESULT there are the "labels" of the fields whose values are there. <?php $con=mysqli_connect("localhost","root","","activitytest1"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (isset($_POST['submit'])) { $stmt = mysqli_prepare($con, "INSERT INTO activitytest1 (type, author, taskpre, taskdescription, outcome, semipre, semiwhile, exercisedescription, practicepre, practiceinstructions, leadin, gamepre, gameinstructions, videopre, videowhile, videopost, songpre, songwhile, songpost, mimioinstructions, otherinstructions, path, books, grouping, time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); mysqli_stmt_bind_param($stmt, 'sssssssssssssssssssssssss', $type, $author, $taskpre, $taskdescription, $outcome, $semipre, $semiwhile, $exercisedescription, $practicepre, $practiceinstructions, $leadin, $gamepre, $gameinstructions, $videopre, $videowhile, $videopost, $songpre, $songwhile, $songpost, $mimioinstructions, $otherinstructions, $path, $books, $grouping, $time); $type = $_POST['type']; $author = $_POST['author']; $taskpre = $_POST['taskpre']; $taskdescription = $_POST['taskdescription']; $outcome = $_POST['outcome']; $semipre = $_POST['semipre']; $semiwhile = $_POST['semiwhile']; $exercisedescription = $_POST['exercisedescription']; $practicepre = $_POST['practicepre']; $practiceinstructions = $_POST['practiceinstructions']; $leadin = $_POST['leadin']; $gamepre = $_POST['gamepre']; $gameinstructions = $_POST['gameinstructions']; $videopre = $_POST['videopre']; $videowhile = $_POST['videowhile']; $videopost = $_POST['videopost']; $songpre = $_POST['songpre']; $songwhile = $_POST['songwhile']; $songpost = $_POST['songpost']; $mimioinstructions = $_POST['mimioinstructions']; $otherinstructions = $_POST['otherinstructions']; $path = $_POST['path']; $books = $_POST['books']; $grouping = $_POST['grouping']; $time = $_POST['time']; $submit = $_POST['submit']; mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); } $result = mysqli_query($con,"SELECT * FROM activitytest1"); while($row = mysqli_fetch_array($result)) { echo "<table width='909' border='1' align='center' cellpadding='5' cellspacing='0'> <tr> <th width='125' scope='col'>Type</th> <th width='680' scope='col'>Description</th> <th width='120' scope='col'>Author</th> </tr></table> <br/> <table width='909' border='1' align='center' cellpadding='5' cellspacing='0'> <tr> <td width='125'>" . $row['type'] . "</th> <td width='680'>Time:" . $row['time'] . " min. <br><br>" . $row['books'] . "<br/>Grouping: " . $row['grouping'] . "<br/>Preview the Task:" . $row['taskpre'] . "<br/>Instructions:" . $row['taskdescription'] . "<br/>Outcome:" . $row['outcome'] . "<br/>Preview the semi-task:" . $row['semipre'] . "<br/>Instructions:" . $row['semiwhile'] . "<br/>Exercise Instructions: " . $row['exercisedescription'] . "<br/> Preview the Practice:" . $row['practicepre'] . "<br/>Practice Instructions:" . $row['practiceinstructions'] . "<br/>Lead-in:" . $row['leadin'] . "<br/>Preview the Game:" . $row['gamepre'] . "<br/>Game Instructions:" . $row['gameinstructions'] . "<br/>Song PRE:" . $row['songpre'] . "<br/>Song WHILE:" . $row['songwhile'] . "<br/>Song POST:" . $row['songpost'] . "<br/>Video PRE:" . $row['videopre'] . "<br/>Video WHILE:" . $row['videowhile'] . "<br/>Video POST:" . $row['videopost'] . "<br/>Mimio Instructions:" . $row['mimioinstructions'] . "<br/>Instructions:" . $row['otherinstructions'] . "<br/><br>Link/Path" . $row['path'] . "<br/></th> <td width='120'>" . $row['author'] . "</th> </tr></table> <br/> <hr size='1'/>"; } mysqli_close($con); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test 1</title> </head> <body> <br> <table width="909" border="1" align="center" cellpadding="5" cellspacing="0"> <tr> <th width="125" scope="col">Type</th> <th width="680" scope="col">Description</th> <th width="120" scope="col">Author</th> </tr></table> <br> <form action="index.php" method="POST"> <table width="909" border="1" align="center" cellpadding="5" cellspacing="0"> <td width="125"><label> </label> <select name="type" id="type" onChange="display(this,'Task','Semi-task','Practice','Exercise','Lead-in', 'Game', 'Video','Song','Mimio','Other');"> <option value="Unselected" selected="selected">Choose one:</option> <option value="Task">Task</option> <option value="Semi-task">Semi-task</option> <option value="Practice">Practice</option> <option value="Exercise">Exercise</option> <option value="Lead-in">Lead-in</option> <option value="Game">Game</option> <option value="Video">Video</option> <option value="Song">Song</option> <option value="Mimio">Mimio</option> <option value="Other">Other</option> </select></td> <td width="680"><div id="Task" style="display:none"> Task: <br /> Lead-in/Preview the task: <textarea name="taskpre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="taskdescription" cols="70" rows="2"></textarea> <br /> Outcome: <textarea name="outcome" cols="70" rows="2"></textarea> <br /> </div> <div id="Semi-task" style="display:none">Semi-task:<br /> Lead-in/Preview the task: <textarea name="semipre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="semiwhile" cols="70" rows="2"></textarea> <br /> </div> <div id="Exercise" style="display:none">Exercise:<br /> Instructions/Obs.: <textarea name="exercisedescription" cols="70" rows="2"></textarea> </div> <div id="Practice" style="display:none"> Practice:<br /> Lead-in/Preview the task: <textarea name="practicepre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="practiceinstructions" cols="70" rows="2"></textarea> <br /> </div> <div id="Lead-in" style="display:none"> Lead-in:<br> <textarea name="leadin" cols="70" rows="2"></textarea><br> </div> <div id="Game" style="display:none"> Game:<br /> Lead-in: <textarea name="gamepre" cols="70" rows="2"></textarea> <br /> Instructions: <textarea name="gameinstructions" cols="70" rows="2"></textarea> </div> <div id="Video" style="display:none"> Video: <br /> Pre: <textarea name="videopre" cols="70" rows="2"></textarea> <br /> While: <textarea name="videowhile" cols="70" rows="2"></textarea> <br /> Post: <textarea name="videopost" cols="70" rows="2"></textarea> </div> <div id="Song" style="display:none"> Song: <br /> Pre: <textarea name="songpre" cols="70" rows="2"></textarea> <br /> While: <textarea name="songwhile" cols="70" rows="2"></textarea> <br /> Post: <textarea name="songpost" cols="70" rows="2"></textarea> </div> <div id="Mimio" style="display:none">Mimio:<br /> Instructions:<br> <textarea name="mimioinstructions" cols="70" rows="2"></textarea> </div> <div id="Other" style="display:none">Other:<br /> Instructions:<br> <textarea name="otherinstructions" cols="70" rows="2"></textarea><br /> </div> </td> <td width="120"><input name="author" type="text" size="12" maxlength="25" /></td> </tr> <tr> <td colspan="3"> <select name="books" id="Books"> <option value="books open" selected="selected">books open</option> <option value="books closed">books closed</option> </select> <br /> <select name="grouping"> <option value="individual" selected="selected">individual</option> <option value="pairs">pairs</option> <option value="trios">trios</option> <option value="groups of 3 to 4 students">groups of 3 to 4 students</option> <option value="groups of 5 students">groups of 5 students</option> <option value="divide the class into 2 groups">divide the class into 2 groups</option> <option value="divide the class into 3 groups">divide the class into 3 groups</option> <option value="divide the class into 4 groups">divide the class into 4 groups</option> </select> <br /> about <input name="time" type="text" id="Time" size="1" /> min </td> </tr> <tr> <td colspan="3">Link/Path: <input name="path" type="text" id="Path" size="40" /></td> </tr> <tr> <td colspan="3"><input type="submit" name="submit" value="Post!" /></td> </tr> </table> </form> </body> </html>
  2. Hello all, I am trying to make a determination about the best way to move forward with my database code for both personal projects and for the company I work for. For my own projects, I used to use mysql functions but have started to switch over to PDO. The company I work for is still using mysql functions and they are a bit wary about switching over to either mysqli or pdo, as they have a lot of code to go through and they don't want to make a bad decision. So I started working on a database class that would replicate all of the mysql functions they were used to (fetch_assoc, fetch_array, num_rows, etc) and decided to make it so that, via a config, you could use mysqli OR pdo and then, in each function, it would do it's best to get the expected result. This way, the code for the company would only ever have to do something like: $db->query($sql); if($db->num_rows() > 0) etc... But the more I read up on PDO (which I have been using in a more proceedural way), it seems like this is already a wrapper, so in effect I'm wrapping a wrapper. So, bottom line, what are others doing to future proff their database code? I like the idea of a class with generic function names, because if there is ever another style to use (mysqlii?) we can just write up the proper functions inside of the existing class and they'll work without a hitch. But is this something that pdo already delivers? I know it's good for dealing with multiple types of databases (mysql, mssql, oracle) but this company will only ever be working with mysql, so I don't have to go overboard with considerations for that. Thanks for any help/advice! JD
  3. so I have a query that I need to basically split in half to display in two section on the web page. I have a left side and a right side that will be filled with random selected images from the database. <body> <div class="leftbar"> 4 images here </div> <div class="maincontent"> main content of viewed page </div> <div class="rightbar"> next 4 images here </div> </body> is there a way this can be done? the query i would be using would look like this... except I need to spit the results in half to display in the two "leftbar" and "rightbar" sections $images = mysqli_query($con, "SELECT * FROM pictures ORDER BY RAND() LIMIT 8") or die("Image Query Failed: ".mysqli_error($con));
  4. Insert function not working like the select functions are.. :~ I have a functions file that contains a number of mysqli_query query's that other php pages successfully call, including the page in question. For round numbers I have 10 functions total. Of the 10, 9 are select query's, 1 is an insert. All of the select query's work including 2 on the page in question. These 2 query's populate 2 drop down menus in a form. When I submit the form I am $_POST ing all the fields to another PHP file that parses the data, calls the insert function -> sends the values, then sends an e-mail using PHPMailer.. When I call the Insert query (submit the form), I am returned "Error updating databaseNo database selected" Error. All of the php pages have an include statement on top pointing to a connection file. IF I put a DB connection string inside the insert function, per below, the insert function works when called.. There's gotta be something basic I'm missing with how I have my stuff setup.. Does anybody have advice? Or I guess I could have everything on one page / file.... mysql_connect("server", "user", "pass") or die('Can\'t connect because:' .mysql_error()); mysql_select_db ("database"); thanx
  5. I am getting this error 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 '' at line 1 This is the code I used: $sql = mysqli_query($con, "SELECT * FROM ".decrypt($_SESSION["name"], ENCRYPTION_KEY)."_table "); while ($row = mysqli_fetch_array($con)) { // displays data } echo mysqli_error($con); I don't know what the problem is,but when I do this:echo "SELECT * FROM ".decrypt($_SESSION["name"], ENCRYPTION_KEY)."_table "); I am getting this: SELECT * FROM ab_table The above query is correct,but why does it flag an error?
  6. I am trying to create MySQL database using PHP. Here is my code. db-config.php <html> <head> <title> Database Configuration </title> </head> <body> <?php $host = "localhost"; $user = "root"; $pass = "123456789"; $database = "hello"; $mysql = new mysqli($host,$user,$pass); if($mysql->connect_error) { die ("Could not connect to database"); } ?> createdb.php <html> <head> <title> Create tables </title> </head> <body> <?php include("\db-config.php"); if(!$a = ($mysql->query("CREATE DATABASE $database")))die("Could not create database"); echo "Successfully created database"; $table = "user"; $td = "userid MEDIUMINT(10) DEFAULT '0' NOT NULL AUTO_INCREMENT,"; $td .= "username VARCHAR(20) BINARY NOT NULL,"; $td .= "password VARCHAR(20) BINARY NOT NULL,"; $td .= "name VARCHAR(20) BINARY NOT NULL"; $test = $mysql->query("SELECT DATABASE $database"); if(!(mysqli_select_db($mysql,$database)))die("Could not connect to database"); if(!(mysqli_query("CREATE TABLE $table ($td)")))die("Could not create tables"); echo "Successfully created tables"; ?> </body> </html> It always results in die message. Please help.
  7. Hello everyone. I am new to PHP/SQL. I tried to display tables from a database using PHP and MySQli functions(not MySQL). But I failed. Can anyone tell me how to do it.Also please explain me the code, Thank You.
  8. I am working on converting legacy queries to mysqli prepared statements. My SELECT queries are working fine, but ADD/DELETE/UPDATE are giving me problems. I have found many online examples showing bind statements for ADD/DELETE/SELECT, including the use of call_user_func_array() but others claim that bindings are not necessary when writing records (as opposed to reading them). So I am confused about this issue, and when I use bind statements I get the following error message: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /srv/www/htdocs/PNS/Complex/writeRec5.php on line 177 bind_param()error : The following are snippets of code using dummy values to simplify the code for testing along with output. I reaIize that call_user_func_array() is not necessary in this simple example, but I will need it for the project. I don't see the error, and I have compared it to many online forum examples which claim to be functioning. Does anything stand out? $prepareString = "Address=?,Permit_Rate=?"; echo "<b>PrepareString: </b>",$prepareString,"<br /><br />"; $Address="123 Somewhere Street";$Permit_Rate=25; $sql="UPDATE table1 SET " . $prepareString . " WHERE Key_ID = " . $keyid; echo $sql,"<br /><br />"; Output: PrepareString: Address=?,Permit_Rate=? UPDATE table1 SET Address=?,Permit_Rate=? WHERE Key_ID = 2664 $stmt = $mysqli->prepare($sql); if (false === $stmt) {die('Query Prep Failed' . $mysqli->error);} $dataTypes="si";$bindParams=array(&$Address,&$Permit_Rate); echo "<b>Length of dataTypes: </b> ",strlen($dataTypes),": <b>Contents of dataTypes: </b>",$dataTypes,"<br />"; echo "<b>Count of bindParams: </b>",count($bindParams)," <b>Contents of bindParams: </B>"; var_dump($bindParams); echo "<br /><br />"; Output: Length of dataTypes: 2: Contents of dataTypes: si Count of bindParams: 2 Contents of bindParams: array(2) { [0]=> &string(20) "123 Somewhere Street" [1]=> &int(25) } $x = call_user_func_array(array($stmt, 'bind_result'), &$bindParams); if (false === $x) {die('bind_param()error :' . $mysqli->error);} $stmt->execute();$stmt->close(); Output: Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in /srv/www/htdocs/PNS/Complex/writeRec5.php on line 177 bind_param()error :
  9. I am trying to pass several parameters dynamically to the bind_param() function. Here is the error i receive: Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given $con = new mysqli('localhost',USER,PASS,DBS); if(mysqli_connect_errno()) { error(mysqli_connect_errno()); } $con -> set_charset("utf8"); /*inside*/ $type=''; $query='SELECT bugID FROM bug'; if(!empty($_GET['cena'])) { $build[]='uCena=?'; $type.='i'; $val[]=$_GET['cena']; } if(!empty($_GET['popust'])) { $build[]='uPopust=?'; $type.='i'; $val[]=$_GET['popust']; } if(!empty($build)) { echo $query .= ' WHERE '.implode(' AND ',$build); } $new = array_merge(array($type),$val); foreach($new as $key => $value) { $tmp[$key]=&$new[$key]; } echo '<br/><br/>'; foreach ($new as $new ){ echo "$new<br/>"; } if ($count = $con->prepare($query)) { call_user_func_array(array($count,'bind_param'),$tmp); $count->execute(); $cres = $count->fetch_row(); $count -> close(); } else error($con->error); /*inside*/ $con -> close();
  10. I would like to dynamically pass data for bind parameters, depending on user selection. This code gives me two errors: Warning: Invalid argument supplied for foreach() Warning: Wrong parameter count for mysqli_stmt::bind_param() $query="SELECT COUNT(*) FROM database WHERE parameter_zero ='approved'"; if(!empty($_GET['first_parameter'])) { $queryPart[] = 'first_parameter=?'; $type[]='s'; $value[]=$_GET['first_parameter']; } if(!empty($_GET['second_parameter'])) { $queryPart[] = 'second_parameter=?'; $type[]='s'; $value[]=$_GET['second_parameter']; } if(!empty($_GET['third_parameter'])) { $queryPart[] = 'third_parameter=?'; $type[]='s'; $value[]=$_GET['third_parameter']; } $query.= ' AND '.implode(' AND ',$queryPart); $bind=array_merge($type,$value); if ($res = $con->prepare($query)) { call_user_func_array(array($count,'bind_param'),ref($bind)); $res->execute(); $cRes = $res-> $fetch_row(); $count -> close(); } else error($con->error); echo $cRes; function ref($arr) { $refs=array(); foreach($arr as $key => $value) { $refs[$key] = &$arr[$key]; } return $refs; }
  11. I noticed a bug in my script and i have been searching a lot on internet since past few hours but i could not find any information or solution. The script runs fine, no errors, but the script does not fetch last row/entry. Example, if there are 3 rows in the table, my script only pulls 2 rows. If there are 10, then only 9 are fetched. Please help me find the bug. Here is my script... <?php $query = "SELECT * FROM members WHERE $condition_res ORDER BY id DESC LIMIT $startpoint, $limit"; $result_query = mysqli_query($mysqli, $query); while($row = @mysqli_fetch_assoc($result_query)) { $mid=$row["id"]; $member=$row["name"]; $gender= $row["gender"]; ?> <tr> <td><?php echo $mid; ?></td> <td><?php echo $member; ?></td> <td><?php echo $gender; ?></td> </tr> <?php } ?> Note: $startpoint and $limit variables are for Pagination. $condition_res is for search criteria.
  12. Having a tough time getting multiple select count statements to return a result. Tried a few different way, but just looking to tally individual table rows. Any thoughts? $res = array(); //output array $query = "SELECT COUNT(*) AS count FROM tbl_1"; //assign count to an alias (column), but tried it without also $query .= "SELECT COUNT(*) AS count FROM tbl_2"; if($mysqli->multi_query($query)){ do { if ($result = $mysqli->store_result()) { $row = $result->fetch(); //tried this with fetch_row() and while loop $res[] = $row['count']; } else { echo "store result returned false."; } $result->free(); } while ($mysqli->more_results() && $mysqli->next_result()); } $mysqli->close(); print_r($res); Thanks in advance.
  13. I am trying to run the following: $sqlErrors = ""; $query = "SELECT `name` FROM company WHERE id=".$_POST['companyID']; $result = $mysqli->query($query); $row = $result->fetch_assoc(); $company = $row['name']; $sqlErrors = $mysqli->error ? "Selecting company, id: ".$_POST['companyID'].". Error: ".$mysqli->error : ""; And am getting the following output: Fatal error: Call to undefined method mysqli::SELECT `name` FROM company WHERE id=3() I have no idea where the trailing brackets are coming from, and even tried $result = $mysqli->query("SELECT `name` FROM company WHERE id=3"); ... but get the same result. The questionable piece of code is contained within the following, in the "what company are we regestering the agent to?" section. $all_query_ok = true; $sqlErrors = ""; /* connect to the db */ $mysqli = new mysqli('localhost','riski296_dbuser','7FJTCJyMARer90oCKmyek5Cw36wXYG1etWJcOGjYONn53liYEHkTb0v74WqpVV3O', 'riski296_taxi_pim') or die('Cannot select the DB'); /* * what company are we regestering the agent to? */ $query = "SELECT `name` FROM company WHERE id=".$_POST['companyID']; $result = $mysqli->query($query); $row = $result->fetch_assoc(); $company = $row['name']; $sqlErrors = $mysqli->error ? "Selecting company, id: ".$_POST['companyID'].". Error: ".$mysqli->error : ""; /* grab the first available agnet for that company */ $agentID = -1; if ($result = $mysqli->query("SELECT id FROM agent WHERE is_active=0 AND companyID=".$_POST['companyID']." LIMIT 1")) { if($result->num_rows == 1){ /* fetch object array */ $row = $result->fetch_assoc(); $agentID = $row['id']; } else { echo "There is no agents currently entered for ".$company; exit(); } $sqlErrors .= $mysqli->error ? ". Getting agent, company id: ".$_POST['companyID'].". Error: ".$mysqli->error : ""; } /* determine what kind of connection device is being used */ $connectionDeviceID = -1; switch($_POST['connectionDeviceType']) { case "Cellular": $connectionDeviceID = $_POST['cellularConnectionDeviceID']; break; case "LAN": $connectionDeviceID = $_POST['lanConnectionDeviceID']; break; } $mysqli->autocommit(FALSE); /* * INSERT connection device being used with this PIM */ $mysqli->$query(" INSERT INTO connection_device (idDevices, device_type, idPlan) VALUES (".$connectionDeviceID.", ".$_POST['connectionDeviceType'].", ".$_POST['planID'].")") ? null : $all_query_ok = false; $sqlErrors .= $mysqli->error ? ". Inserting connection_device, connection device id: ".$connectionDeviceID.", Connection device type: ".$_POST['connectionDeviceType'].", and Plan ID: ".$_POST['planID'].". Error: ".$mysqli->error : ""; /* * INSERT PIM and associate the connection device with the PIM */ $mysqli->$query(" INSERT INTO device (idDevices, idAgent, idConnectionDevice) VALUES (".$_POST['pimID'].", NULL, ".$mysqli->insert_id.")") ? null : $all_query_ok = false; $sqlErrors .= $mysqli->error ? ". Inserting PIM, PIM id: ".$_POST['pimID'].", agent ID: NULL, and Plan ID: ".$_POST['planID'].". Error: ".$mysqli->error : ""; /* * associate the device with the company. make note of install date */ $install_date = date("Y-m-d H:i:s"); $mysqli->$query(" INSERT INTO compay_device_relation (idCompany, idDevice, install_date, location, removal_date) VALUES (".$_POST['companyID'].", ".$mysqli->insert_id.", ".$install_date.", NULL, NULL)") ? null : $all_query_ok = false; $sqlErrors .= $mysqli->error ? ". Inserting company_device_relation, idCompany: ".$_POST['companyID'].", idDevice: ".$mysqli->insert_id.", install_date: ".$install_date.", location: NULL, and removal_date: NULL. Error: ".$mysqli->error : ""; /* * check for any pre-existing errors */ if($sqlErrors != "") { echo $sqlErrors; exit(); } /* * update agent - this makes sure that the agent is still available */ $mysqli->query("UPDATE agent SET is_active=1 WHERE id=".$agentID) ? null : $all_query_ok = false; $mysqli->affected_rows == 1 ? null : $all_query_ok = false; $all_query_ok ? $mysqli->commit() : $mysqli->rollback(); $mysqli->autocommit(TRUE); $mysqli->close(); echo $all_query_ok ? "Agent added to ".$company : "failure:"; Any help is most appreciated! Thanks, Dave.
  14. Hi guys can you all please help me. I am stuck with my script it keep inputting errors: Script below thanks <?php session_start(); $password=$_GET['password']; include("phpfiles/maindb.php"); connect(); if(!isset($_POST['password'])){ $sql="select email from users where password='".$password."' and id=0"; $query = mysqli_query($maindb, $sql); while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){ $email=$row['email']; } If ($email!=''){ $_SESSION['email']=$email; } else die("Invalid link or Password already changed");} $password=$_POST['password']; $email=$_SESSION['email']; if(!isset($password)){ echo '<form method="post"> enter your new password:<input type="password" name="password" /> <a href="index.php><input type="submit" value="Change Password">Back</span></a> </form>';} if(isset($_POST['password'])&&isset($_SESSION['email'])) { $sql="update users set password='".md5($password)."' where email='".$email."'"; $query = mysqli_query($maindb, $sql); if(mysqli_query($maindb, $sql), "update users set id=1 where password='".$password."'"); echo "Your password has been changed successfully"; if(!$query)echo "An error occurred"; } ?>
  15. so I hope some of you understand kinda whats going on just from the title... mainly of course I have a content element that is going outside the area of the container for it. I have a screen shot of whats going on. now I've tried lots of things to see if I can fix this issue but I am still stumped after a few weeks trying to deal with this. now I know lots of people get this every once in a while, just for me i am lost in what to do about this issue, yes its a tabbed content box all in CSS, no JS or JQ for the tab. For the code, there is a lot involved in this one page, I will post everything to deal with this one page excluding my connectiong script for mysql Main Page Code: <!doctype html> <!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]--> <!--[if IE 7]> <html class="ie7 oldie"> <![endif]--> <!--[if IE 8]> <html class="ie8 oldie"> <![endif]--> <!--[if gt IE 8]><!--> <html> <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Pure Audio Centre</title> <link href="boilerplate.css" rel="stylesheet" type="text/css"> <link href="layout.css" rel="stylesheet" type="text/css"> <link href="style.css" rel="stylesheet" type="text/css"> <link href="menu.css" rel="stylesheet" type="text/css"> <link href="test.css" rel="stylesheet" type="text/css"> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="respond.min.js"></script> </head> <body> <div class="gridContainer clearfix"> <div id="Header"><img src="images/logo.png" style="padding-left:15px;" /> <div class="head_info"> Phone: (250) 871-PURE(7873)<br /> #2 - 720 30th STREET<br /> Courtenay BC, V9N 7S7 </div> </div> <div id="Menu"> <nav> <a href="index.php"><div class="home"></div></a><div class="dots"><img src="images/menu_dots.png"></div> <a href="products.php"><div class="products2"></div></a><div class="dots"><img src="images/menu_dots.png"></div> <a href="specials.php"><div class="specials"></div></a><div class="dots"><img src="images/menu_dots.png"></div> <a href="services.php"><div class="services"></div></a><div class="dots"><img src="images/menu_dots.png"></div> <a href="contact.php"><div class="contact"></div></a> </nav> </div> <div id="Menu2"> Home : Products : Speacials : Services : Contact </div> <div id="contain"> <div id="leftbar"> <div class="block"> JL Audio Stealthbox <br /> <img src="images/companylogo/x01_447006.png" width="150px" /><br /> <img src="images/companylogo/JL-Audio-Stealth-Box.png" width="150px" /> </div> </div> <div id="Main"> <div class="block-main"> <center> <?php echo '<div class="content">'; include 'connect.php'; $page = $_GET['page']; $get_company = $_GET['name']; $model = $_GET['model']; $get_id = $_GET['id']; switch($page) { case "product_info": echo '<div class="bread"><div id="pad_content"><a href="products.php">Products</a> > <a href="products.php?page=company&name=' . $get_company . '">' . $get_company . '</a> > ' . $model . '</div></div>'; echo '<div class="c_header"><div id="pad_content">' . $get_company . ' ' . $model . '</div></div>'; echo '<div class="c_taber"><div id="pad_content">'; echo '<a href="images/product/'.$get_company.'-'.$model.'.png"><img src="images/product/'.$get_company.'-'.$model.'-thumb.png"></a>'; $tab_results = mysqli_query($con,"SELECT * FROM product_info WHERE tabs='" . $get_id . "'") or die('Tab Results error: '. mysqli_error($con)); if(!$tab_results){ echo 'No Information at This Time. Please Come Back Later.'; } ?> <div class="container-tab"> <article class="tabs"> <?php while($row = mysqli_fetch_array($tab_results)) { extract($row); ?> <span id="<?php echo $id; ?>" class="anchor"></span> <div class="panel"> <a class="tab-link" href="#<?php echo $id; ?>"><?php echo $tab_name; ?></a> <div> <?php echo $content; ?> </div> </div> <?php } ?> </article> </div> <?php echo '</div></div>'; echo '<div class="c_date"><div id="pad_content"></div></div>'; break; case "company": echo '<div class="bread"><div id="pad_content"><a href="products.php">Products</a> > ' . $get_company . ' ></div></div>'; echo '<div class="c_header"><div id="pad_content">'. $get_company .' Products</div></div>'; echo '<div class="c_content"><div id="pad_content">'; $product_result = mysqli_query($con,"SELECT * FROM products WHERE company='". $get_company ."'") or die('Result error: '. mysqli_error($con)); $row_product = mysqli_num_rows($product_result); if($row_product == 0){ echo 'No Information at This Time. Please Come Back Later.'; } while($row = mysqli_fetch_array($product_result)) { extract($row); echo '<a href="products-2.php?page=product_info&name=' . $get_company . '&model=' . $model . '&id=' . $id . '">' . $product_name . '</a>'; } echo '</div></div>'; echo '<div class="c_date"><div id="pad_content"></div></div>'; break; default: echo '<div class="bread"><div id="pad_content">Products ></div></div>'; echo '<div class="c_header"><div id="pad_content">Manufacture</div></div>'; echo '<div class="c_content"><div id="pad_content">'; $company_result = mysqli_query($con,"SELECT * FROM manufacture") or die('Result error: '. mysqli_error($con)); $row_company = mysqli_num_rows($company_result); if($row_company = 0){ echo 'No Information at This Time. Please Come Back Later.'; } while($row = mysqli_fetch_array($company_result)) { extract($row); echo '<a href="products-2.php?page=company&name=' . $company . '">' . $company . '</a> : '; } echo '</div></div>'; echo '<div class="c_date"><div id="pad_content"></div></div>'; } echo '</div>'; ?> </center> </div> </div> <div id="rightbar"> <div class="block"> Custom Boxes<br /> <img src="images/companylogo/883396_496430483737520_2127125254_o.png" width="150px" /><br /> <img src="images/companylogo/886750_491317497582152_1975245904_o.png" width="150px" /><br /> SPL Meter!!<br /> <img src="images/companylogo/901979_496429530404282_1320296857_o.png" width="150px" /> </div> </div> </div> <div id="Featured"> <div class="fbox1"><img src="images/companylogo/Pacific-Accessory-Corp-logo.png" width="160px" /></div> <div class="fbox2"><img src="images/companylogo/focal-logo-pack1.png" /></div> <div class="fbox2"><img src="images/companylogo/Metra-logo.png" /></div> <div class="fbox1"><img src="images/companylogo/morel-logo.png" /></div> </div> <div id="Footer">2013 Pure Audio Centre All Rights Reserved.<br />Designed & Developed by GuberX.</div> </div> </body> </html> Boilerplate.css @charset "utf-8"; /* ========================================================== normalize ==========================================================*/ * { -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */ } /* ============================================================================= HTML5 display definitions ========================================================================== */ article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } audio:not([controls]) { display: none; } [hidden] { display: none; } /* ============================================================================= Base ========================================================================== */ html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } body { margin: 0; font-size: 13px; line-height: 1.231; } body, button, input, select, textarea { font-family: sans-serif; color: #222; } /* ============================================================================= Links ========================================================================== */ a { color: #00e; } a:visited { color: #551a8b; } a:hover { color: #06e; } a:focus { outline: thin dotted; } /* Improve readability when focused and hovered in all browsers: h5bp.com/h */ a:hover, a:active { outline: 0; } /* ============================================================================= Typography ========================================================================== */ abbr[title] { border-bottom: 1px dotted; } b, strong { font-weight: bold; } blockquote { margin: 1em 40px; } dfn { font-style: italic; } hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } ins { background: #ff9; color: #000; text-decoration: none; } mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; } /* Redeclare monospace font family: h5bp.com/j */ pre, code, kbd, samp { font-family: monospace, monospace; _font-family: 'courier new', monospace; font-size: 1em; } /* Improve readability of pre-formatted text in all browsers */ pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } q { quotes: none; } q:before, q:after { content: ""; content: none; } small { font-size: 85%; } /* Position subscript and superscript content without affecting line-height: h5bp.com/k */ sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } sup { top: -0.5em; } sub { bottom: -0.25em; } /* ============================================================================= Lists ========================================================================== */ ul, ol { margin: 1em 0; padding: 0 0 0 40px; } dd { margin: 0 0 0 40px; } nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; } /* ============================================================================= Embedded content ========================================================================== */ img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; } /* * Correct overflow not hidden in IE9 */ svg:not(:root) { overflow: hidden; } /* ============================================================================= Figures ========================================================================== */ figure { margin: 0; } /* ============================================================================= Forms ========================================================================== */ form { margin: 0; } fieldset { border: 0; margin: 0; padding: 0; } /* Indicate that 'label' will shift focus to the associated form element */ label { cursor: pointer; } /* * 1. Correct color not inheriting in IE6/7/8/9 * 2. Correct alignment displayed oddly in IE6/7 */ legend { border: 0; *; padding: 0; } /* * 1. Correct font-size not inheriting in all browsers * 2. Remove margins in FF3/4 S5 Chrome * 3. Define consistent vertical alignment display in all browsers */ button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; } /* * 1. Define line-height as normal to match FF3/4 (set using !important in the UA stylesheet) * 2. Correct inner spacing displayed oddly in IE6/7 */ button, input { line-height: normal; *overflow: visible; } /* * Reintroduce inner spacing in 'table' to avoid overlap and whitespace issues in IE6/7 */ table button, table input { *overflow: auto; } /* * 1. Display hand cursor for clickable form elements * 2. Allow styling of clickable form elements in iOS */ button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; } /* * Consistent box sizing and appearance */ input[type="checkbox"], input[type="radio"] { box-sizing: border-box; } input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } /* * Remove inner padding and border in FF3/4: h5bp.com/l */ button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } /* * 1. Remove default vertical scrollbar in IE6/7/8/9 * 2. Allow only vertical resizing */ textarea { overflow: auto; vertical-align: top; resize: vertical; } /* Colors for form validity */ input:valid, textarea:valid { } input:invalid, textarea:invalid { background-color: #f0dddd; } /* ============================================================================= Tables ========================================================================== */ table { border-collapse: collapse; border-spacing: 0; } td { vertical-align: top; } /* ==|== primary styles ===================================================== Author: ========================================================================== */ /* ==|== non-semantic helper classes ======================================== Please define your styles before this section. ========================================================================== */ /* For image replacement */ .ir { display: block; border: 0; text-indent: -999em; overflow: hidden; background-color: transparent; background-repeat: no-repeat; text-align: left; direction: ltr; } .ir br { display: none; } /* Hide from both screenreaders and browsers: h5bp.com/u */ .hidden { display: none !important; visibility: hidden; } /* Hide only visually, but have it available for screenreaders: h5bp.com/v */ .visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } /* Extends the .visuallyhidden class to allow the element to be focusable when navigated to via the keyboard: h5bp.com/p */ .visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; } /* Hide visually and from screenreaders, but maintain layout */ .invisible { visibility: hidden; } /* Contain floats: h5bp.com/q */ .clearfix:before, .clearfix:after { content: ""; display: table; } .clearfix:after { clear: both; } .clearfix { zoom: 1; } /* ==|== print styles ======================================================= Print styles. Inlined to avoid required HTTP connection: h5bp.com/r ========================================================================== */ @media print { * { background: transparent !important; color: black !important; text-shadow: none !important; filter:none !important; -ms-filter: none !important; } /* Black prints faster: h5bp.com/s */ a, a:visited { text-decoration: underline; } a[href]:after { content: " (" attr(href) ")"; } abbr[title]:after { content: " (" attr(title) ")"; } .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } /* Don't show links for images, or javascript/internal links */ pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } thead { display: table-header-group; } /* h5bp.com/t */ tr, img { page-break-inside: avoid; } img { max-width: 100% !important; } @page { margin: 0.5cm; } p, h2, h3 { orphans: 3; widows: 3; } h2, h3 { page-break-after: avoid; } } DW CS6 FluidGrid "Layout.css" @charset "utf-8"; /* Simple fluid media Note: Fluid media requires that you remove the media's height and width attributes from the HTML http://www.alistapart.com/articles/fluid-images/ */ /* Dreamweaver Fluid Grid Properties ---------------------------------- dw-num-cols-mobile: 5; dw-num-cols-tablet: 8; dw-num-cols-desktop: 10; dw-gutter-percentage: 25; Inspiration from "Responsive Web Design" by Ethan Marcotte http://www.alistapart.com/articles/responsive-web-design and Golden Grid System by Joni Korpi http://goldengridsystem.com/ */ /* Mobile Layout: 480px and below. */ .gridContainer { margin: 0 auto; width: 96%; } #Header { clear: both; float: left; margin-left: 0; width: 100%; display: block; } #Menu { clear: both; float: left; margin-left: 0; width: 100%; display: none; } #Menu2 { clear: both; float: left; width: 100%; display: block; text-align: center; } #Footer { clear: both; float: left; margin-left: 0; width: 480px; display: block; } #Main { clear: both; float: left; margin-left: 0; width: 100%; display: block; } #leftbar { clear: both; float: left; display: none; } #rightbar { clear: both; float: left; display: none; } #Featured { clear: both; float: left; margin-left: 0; width: 100%; display: block; } .feature { display: none; } .fbox1 { display: none; } .fbox2 { display: none; } .head_info { display: block; float: right; margin: 30px 30px 0 0; font-weight: bold; } /* Tablet Layout: 481px to 768px. Inherits styles from: Mobile Layout. */ @media only screen and (min-width: 768px) { .gridContainer { width: 768px; margin: 0 auto; } #Header { clear: both; float: inherit; margin: 0 auto; width: 768px; display: block; background: url(images/header_top.png) no-repeat; height: 141px; } #Menu { clear: both; float: inherit; margin: 0 auto; width: 768px; display: block; background:url(images/menu_bg.png) no-repeat; height: 78px; text-align: center; } #Menu2 { clear: both; float: left; margin: 0 auto; display: none; } #Footer { clear: both; float: inherit; margin: 0 auto; height: 73px; width: 768px; display: block; background:url(images/main_box_footer-2.png) no-repeat; text-align: center; padding-top: 20px; } #Main { clear: none; margin: 0; width: 768px; min-height: 450px; display: table-cell; background: url(images/main_box_top-2.png) no-repeat; } #leftbar { clear: none; display: none; } #rightbar { clear: none; display: none; } #Featured { clear: both; float: inherit; margin: 0 auto; width: 728px; display: block; } #contain { width: 768px; margin: 0 auto; } .feature { display: block; width: 708px; height: 188px; background: url(images/feature_box.png) no-repeat; } .fbox1 { display: inline-block; background: url(images/mini_box_blue.png) no-repeat; width: 179px; height: 179px; } .fbox2 { display: inline-block; background: url(images/mini_box_white.png) no-repeat; width: 179px; height: 179px; } .head_info { display: block; float: right; margin: 30px 30px 0 0; font-weight: bold; } } /* Desktop Layout: 769px to a max of 1232px. Inherits styles from: Mobile Layout and Tablet Layout. */ @media only screen and (min-width: 1128px) { .gridContainer { width: 1128px; margin: 0 auto; } #Header { clear: both; float: inherit; margin: 0 auto; width: 768px; display: block; background: url(images/header_top.png) no-repeat; height: 141px; } #Menu { clear: both; float: inherit; margin: auto; width: 768px; display: block; background:url(images/menu_bg.png) no-repeat; height: 78px; text-align: left; } #Menu2 { clear: both; float: left; margin: 0 auto; display: none; } #Footer { clear: both; float: inherit; margin: 0 auto; height: 73px; width: 768px; display: block; background:url(images/main_box_footer-2.png) no-repeat; text-align: center; padding-top: 20px; } #Main { clear: none; margin: 0; width: 768px; min-height: 450px; display: block; background: url(images/main_box_top-2.png) no-repeat; } #leftbar { clear: none; margin: 0; width: 180px; max-width: 180px; min-height: 450px; display: table-cell; background: url(images/side_box_top.png) no-repeat; text-align: center; } #leftbar img { margin-top: 5px; margin-bottom: 5px; border-radius: 10px; box-shadow: 2px 2px 5px #000000; } #rightbar img { margin-top: 5px; margin-bottom: 5px; border-radius: 10px; box-shadow: 2px 2px 5px #000000; } #rightbar { clear: none; margin: 0; width: 180px; max-width: 180px; min-height: 450px; display: table-cell; background:url(images/side_box_top.png) no-repeat; text-align: center; } #Featured { clear: both; float: inherit; margin: 0 auto; width: 728px; height: 179px !important; display: block; } #contain { width: 1128px; margin: 0 auto; } .feature { display: block; position: relative; width: 708px; height: 188px; background: url(images/feature_box.png) no-repeat; } .fbox1 { display: inline-block; position: relative; background: url(images/mini_box_blue.png) no-repeat; width: 179px; height: 179px; line-height: 171px; text-align: center; } .fbox2 { display: inline-block; position: relative; background: url(images/mini_box_white.png) no-repeat; width: 179px; height: 179px; line-height: 171px; text-align: center; } .head_info { display: block; float: right; margin: 30px 30px 0 0; font-weight: bold; } } Style.css /* CSS Document */ body { background: #FAA71A url(images/main_bg.png) no-repeat top center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; font-family: Helvetica, Arial, sans-serif; } .block-main { width: 750px; margin: 8px 12px; } .block { width: 156px; margin: 8px 12px; } .bad { cursor:not-allowed; } .contactinfo { display: inline-block; float: left; } nav { text-align: center; } nav .dots { display: inline-block; position: relative; } .content { display: block; width: 708px; font-weight: bold; text-align: left; padding: 0; } .content .c_header { display: inline-block; background: url(images/t_content.png) no-repeat top; height: 45px; width: 708px; font-size: 18px; line-height: 45px; padding: 0; } .content .c_content { display: inline-block; background: url(images/c_content.png) repeat-y center; width: 708px; text-indent: 2em; padding: 0; height: 100%; } .content .c_taber { display: inline-block; background: url(images/c_content.png) repeat-y center; width: 708px; padding: 0; height: 100%; } .content .c_date { display: inline-block; background: url(images/b_content.png) no-repeat bottom; height: 45px; width: 708px; text-align: right; padding: 0; } .content .bread { display: inline-block; width: 708px; padding: 0; } #pad_content, #pad_content p { padding-top: 0px; padding-left: 12px; padding-right: 12px; padding-bottom: 0; word-spacing: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } Menu.css /* Menu */ nav .home { display: inline-block; position: relative; background: url(images/menu/home.png) no-repeat; background-position: 0 0; width: 85px; height: 33px; top: 12px; } nav .home:hover { background-position: 0 -33px; } nav .products { display: inline-block; position: relative; background: url(images/menu/products.png) no-repeat; background-position: 0 0; width: 148px; height: 33px; top: 12px; } nav .products:hover { background-position: 0 -33px; } nav .specials { display: inline-block; position: relative; background: url(images/menu/specials.png) no-repeat; background-position: 0 0; width: 131px; height: 33px; top: 12px; } nav .specials:hover { background-position: 0 -33px; } nav .services { display: inline-block; position: relative; background: url(images/menu/services.png) no-repeat; background-position: 0 0; width: 134px; height: 33px; top: 12px; } nav .services:hover { background-position: 0 -33px; } nav .contact { display: inline-block; position: relative; background: url(images/menu/contact.png) no-repeat; background-position: 0 0; width: 128px; height: 33px; top: 12px; } nav .contact:hover { background-position: 0 -33px; } nav .home2 { display: inline-block; position: relative; background: url(images/menu/home.png) no-repeat; background-position: 0 -66px; width: 85px; height: 33px; top: 12px; } nav .home2:hover { background-position: 0 -33px; } nav .products2 { display: inline-block; position: relative; background: url(images/menu/products.png) no-repeat; background-position: 0 -66px; width: 148px; height: 33px; top: 12px; } nav .products2:hover { background-position: 0 -33px; } nav .specials2 { display: inline-block; position: relative; background: url(images/menu/specials.png) no-repeat; background-position: 0 -66px; width: 131px; height: 33px; top: 12px; } nav .specials2:hover { background-position: 0 -33px; } nav .services2 { display: inline-block; position: relative; background: url(images/menu/services.png) no-repeat; background-position: 0 -66px; width: 134px; height: 33px; top: 12px; } nav .services2:hover { background-position: 0 -33px; } nav .contact2 { display: inline-block; position: relative; background: url(images/menu/contact.png) no-repeat; background-position: 0 -66px; width: 128px; height: 33px; top: 12px; } nav .contact2:hover { background-position: 0 -33px; } test.css (this is for my tabber content0) @charset "utf-8"; /* CSS Document */ .container-tab { width: 100%; max-width: 960px; margin: 50px auto; font: 90% arial; } article, header { display: block; } header h1, header p { margin:0 auto; position:relative; font-family:Arial, Helvetica, sans-serif; text-align:center; margin-top: 10px; } header a { text-decoration:none; } a:hover { text-decoration:underline; } .tabs { width: 100%; max-width: 600px; background: #ccc; margin: 50px auto 0; position: relative; } span.anchor { position: fixed; display: none; } .panel div { opacity:0; background: #eee; float: left; width: 100%; position: absolute; top: 19px; left: 0; padding: 10px; box-sizing: border-box; line-height: 1.5em; border-radius: 5px; border-top-left-radius: 0; -webkit-transition: all 0.6s ease; -moz-transition: all 0.6s ease; -ms-transition: all 0.6s ease; -o-transition: all 0.6s ease; transition: all 0.6s ease; } .panel .tab-link { margin-top: -20px; float: left; width: 20%; padding: 10px; background: #eee; margin-right: .5%; text-decoration: none; box-sizing: border-box; font-weight: bold; font-size: 1.1em; color: #333; text-align: center; border-top-left-radius: 5px; border-top-right-radius: 5px; -webkit-transition: all 0.6s ease; -moz-transition: all 0.6s ease; -ms-transition: all 0.6s ease; -o-transition: all 0.6s ease; transition: all 0.6s ease; } .panel .tab-link:visited { color: #333; } .anchor:target + .panel div { opacity: 1; background: #ccc; } .anchor:target + .panel .tab-link { background: #ccc; } @media screen and (max-width:300px) { .panel .tab-link { font-size: 0.8em; padding: 12px 10px 12px 10px; } } and then there is just the Respond.min.js for responsive design (not my script, its from GitHub - scottjehl) and my mySQL connection script Now that all of that is there for everyone, I hope I can get some suggestions to help me with his issue... Thanks
  16. Hi, I am using a grid function which creates a data grid based on the query provided. this is rich & now i find that i need to convert all functions into mysqli compatible. below are the error lines // execute the query through the "database" object $this->queryResult = $this->dbRefference->query($this->query); // get the total number of records in the result (ignoring the LIMIT) $this->totalRecords = $this->dbRefference->foundRows; this shows error as "Notice: Undefined property: mysqli_ext::$foundRows " attaching the file for reference. any help is highly appreciated. Thanks class.datagrid-backup.php
  17. Heya everyone, Still working on learning PHP in my college course and I ran into another problem. I'm kind of stumped because the assignment gave me some extra code, told me exactly where to place it and it is not working. It's kind of frustrating lol. Anyhow, perhaps someone could explain why this is not working. This is the code they told me to put into my script. Instructions: Add the following code to check to see if the guest already exists in the database. Place the code immediately above the INSERT query as part of your validation routines. //Check to see if guest already exists in the database $query = "SELECT * from guests WHERE fname='$fname' AND lname='$lname' AND email='$email'"; if ($result = mysqli_query($connect,$query) or die(mysqli_error($connect))) { echo "You have already signed my guestbook. Thanks!"; } else { YOUR EXISTING INSERT QUERY AND ECHO STATEMENTS DISPLAYING THE QUERY RESULTS ARE HERE } So I did that and here is what it looks like: <?php //Set variable for page title prior to loading header which needs the page title variable. $pagetitle = 'Student, PHP'; //Add in header. include ('includes/header.php'); //Requires the database connection script. require ('includes/connect.php'); ?> <!-- Sticky form displays --> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <legend>Please sign my guest book!</legend> <label for="fname">First: </label><input type="text" name="fname" size="25" maxlength="25" value="<?php if(isset($_POST['fname'])) echo $_POST['fname'];?>"/> <br/> <label for="lname">Last: </label><input type="text" name="lname" size="25" maxlength="25" value="<?php if(isset($_POST['lname'])) echo $_POST['lname'];?>"/> <br/> <label for="email">Email: </label><input type="text" name="email" size="25" maxlength="50" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>"/> <br/> <label for="password">Password: </label><input type="password" name="password" size="10" maxlength="40" value="<?php if(isset($_POST['password'])) echo $_POST['password'];?>"/> <br/> <label for="confirmpass">Confirm Password: </label><input type="password" name="confirmpass" size="10" maxlength="40" value="<?php if(isset($_POST['confirmpass'])) echo $_POST['confirmpass'];?>"/> <br /> <p><b>Comments</b></p> <textarea name="comment" cols="40" rows="10" maxlength="255"><?php if(isset($_POST['comment'])) echo $_POST['comment'];?></textarea> <br/> <input type="reset" value="Reset"/> <input type="submit" name="submit" value="Submit" /> <br/> </fieldset> </form> <?php //Your PHP code to process the submitted form goes here. if ($_SERVER['REQUEST_METHOD'] == 'POST'){ // Perform Validation if (!empty($_POST['fname'])){ if (!empty($_POST['lname'])){ if (!empty($_POST['email'])){ $email = $_POST['email']; if (strstr($email, '@', true)){ if (!empty($_POST['password'])){ if (!empty($_POST['confirmpass'])){ if ($_POST['password'] == $_POST['confirmpass']){ if (!empty($_POST['comment'])){ $comment = mysqli_real_escape_string($connect, trim($_POST['comment'])); } else if (empty($_POST['comment'])){ $comment = NULL; } // assign and trim variables. $fname = mysqli_real_escape_string($connect, trim($_POST['fname'])); $lname = mysqli_real_escape_string($connect, trim($_POST['lname'])); $email = mysqli_real_escape_string($connect, trim($_POST['email'])); $password = mysqli_real_escape_string($connect, trim($_POST['password'])); // Display connection error if any. if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //Check to see if guest already exists in the database $query = "SELECT * from guests WHERE fname='$fname' AND lname='$lname' AND email='$email'"; if ($result = mysqli_query($connect,$query) or die(mysqli_error($connect))) { echo "You have already signed my guestbook. Thanks!"; } else { // Enter user input into database $query = "INSERT INTO guests (fname, lname, email, password, comment) VALUES ('$fname','$lname','$email','$password','$comment')"; // If error kill script and display error. if (!mysqli_query($connect,$query)) { die('Error: ' . mysqli_error($connect)); } // Display success messaage. echo "<h1><p class='message'>Greetings $fname</p></h1>"; echo "<p class='message'>Thank you for signing my guest book!</p>"; // Close database connection. mysqli_close($connect); } // If validation fails display. } else if ($_POST['password'] != $_POST['confirmpass']){ echo '<p class="message">Your password confirmation does not match.</p>';} } else { echo '<p class="message">Please confirm your password.</p>';} } else { echo '<p class="message">Please enter a password.</p>';} } else { echo '<p class="message">Please enter a valid email address.</p>';} } else { echo '<p class="message">Please enter an email address.</p>';} } else { echo '<p class="message">Please enter your last name.</p>';} } else { echo '<p class="message">Please enter your first name.</p>';} } //Add in footer. include ('includes/footer.php'); ?> At the far right of my little pyramid scheme here you can see that I put the required code where it asked me to in the instructions. The problem I have now is that I can not longer enter any new users into the database, it always tells me "You have already signed my Guestbook." If anyone can help me out here I would really appreciate it. I just don't understand exactly what the problem is. As always thanks just for looking. Best Regards, Nightasy
  18. Hi, I am trying to build a table with counted results. My code works unless the count value is 0 (albeit there is likely a much cleaner way to do this and if you have time feel free to share your way) here is what I have: How do I get a count of 0 if the query returns no results? I should mention I get an empty table when the result is 0 <?php // Conection Info $con=mysqli_connect("localhost","*****","*****","*****"); // Check connection if (mysqli_connect_errno()) echo "Failed to connect to MySQL: " . mysqli_connect_error(); // Querys $c_nc_t1 = mysqli_query($con, " SELECT actcaseld, type, encdate, COUNT(type) AS c_nc_t1_type_count FROM `Stats` WHERE type='Type 1' AND actcaseld='New Client' AND encdate BETWEEN (SELECT bdate FROM `ReportRange` WHERE cf_id=1) AND (SELECT edate FROM `ReportRange` WHERE cf_id=1) GROUP BY type"); $c_nc_t2d = mysqli_query($con, " SELECT actcaseld, type, encdate, COUNT(type) AS c_nc_t2d_type_count FROM `Stats` WHERE type='Type 2 diet' AND actcaseld='New Client' AND encdate BETWEEN (SELECT bdate FROM `ReportRange` WHERE cf_id=1) AND (SELECT edate FROM `ReportRange` WHERE cf_id=1) GROUP BY type"); $c_nc_t2a = mysqli_query($con, " SELECT actcaseld, type, encdate, COUNT(type) AS c_nc_t2a_type_count FROM `Stats` WHERE type='Type 2 ADA' AND actcaseld='New Client' AND encdate BETWEEN (SELECT bdate FROM `ReportRange` WHERE cf_id=1) AND (SELECT edate FROM `ReportRange` WHERE cf_id=1) GROUP BY type"); $c_nc_t2ai = mysqli_query($con, " SELECT actcaseld, type, encdate, COUNT(type) AS c_nc_t2ai_type_count FROM `Stats` WHERE type='Type 2 ADA and Insulin' AND actcaseld='New Client' AND encdate BETWEEN (SELECT bdate FROM `ReportRange` WHERE cf_id=1) AND (SELECT edate FROM `ReportRange` WHERE cf_id=1) GROUP BY type"); $c_nc_t2i = mysqli_query($con, " SELECT actcaseld, type, encdate, COUNT(type) AS c_nc_t2i_type_count FROM `Stats` WHERE type='Type 2 Insulin' AND actcaseld='New Client' AND encdate BETWEEN (SELECT bdate FROM `ReportRange` WHERE cf_id=1) AND (SELECT edate FROM `ReportRange` WHERE cf_id=1) GROUP BY type"); // Output to html //Build Headers echo "<center><h3>Report for date range:</h3></center>"; echo "<table border='1' align='center'> <tr> <th></th> <th></th> <th>Type 1</th> <th>Type 2 Diet</th> <th>Type 2 ADA</th> <th>Type 2 ADA + Insulin</th> <th>Type 2 Insulin</th> </tr>"; //Build Data output to html while($row_c_nc_t1=mysqli_fetch_array($c_nc_t1) and $row_c_nc_t2d=mysqli_fetch_array($c_nc_t2d) and $row_c_nc_t2a=mysqli_fetch_array($c_nc_t2a) and $row_c_nc_t2ai=mysqli_fetch_array($c_nc_t2ai) and $row_c_nc_t2i=mysqli_fetch_array($c_nc_t2i)) { echo "<tr>"; echo "<td>Caseload</td><td>New Clients</td> <td><center>" . $row_c_nc_t1['c_nc_t1_type_count'] . "</center></td> <td><center>" . $row_c_nc_t2d['c_nc_t2d_type_count'] . "</center></td> <td><center>" . $row_c_nc_t2a['c_nc_t2a_type_count'] . "</center></td> <td><center>" . $row_c_nc_t2ai['c_nc_t2ai_type_count'] . "</center></td> <td><center>" . $row_c_nc_t2i['c_nc_t2i_type_count'] . "</center></td> "; echo "</tr>"; } echo "</table>"; // Close Connection mysqli_close($con); ?> Thank you in advance for your time and wisdom!
  19. Hi, I am trying to produce a result that requires 2 seperate queries to get the values required to produce the result. It works if I hard code the BETWEEN date values but when I try to pull them from the `Reportrange` table no results are returned. I am using includes to set variables, open and close the connection. (also works if BETWEEN dates are hard coded) See below: The idea is that it can search the `DMCstats` table for a count of each distinct 'gender' value WHERE the 'encdate' matches the range set in `Reportrange` record#1(---->bdate and edate) I think the issue is with the way I am calling the variables $bdat , $edat for $result My apologies in advance if this post does not conform to this forums expectations, its my first post here, feel free to enlighten me! Thanks in advance to all those donating their time for the greater good! Open Connection Include: <?php //Conection Info $con=mysqli_connect("localhost","******","******","******"); // Check connection if (mysqli_connect_errno()) echo "Failed to connect to MySQL: " . mysqli_connect_error(); ?> Close Connection Include: <?php mysqli_close($con); ?> Date Variables include: <?php include 'openconnection.php'; $bdat=mysqli_query($con,"SELECT bdate, FROM `ReportRange` WHERE cf_id=1"); $edat=mysqli_query($con,"SELECT edate, FROM `ReportRange` WHERE cf_id=1"); include 'closeconnection.php'; ?> Gender Query: //Open Connection include 'openconnection.php'; //Set Variables include 'datevars.php'; //Query $result=mysqli_query($con,"SELECT gender,encdate, COUNT(gender) AS gender_count FROM `DMC_Stats` WHERE encdate BETWEEN " . $bdat . " AND " . $edat . " GROUP BY gender"); //Output to html echo "<table border='1'> <tr> <th>Gender</th> <th>Total</th> </tr>"; while($row=mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['gender'] . "</td>"; echo "<td>" . $row['gender_count'] . "</td>"; echo "</tr>"; } echo "</table>"; //Close connection include 'closeconnection.php'; ?> Regards
  20. I’m trying to create a simple web site for people to track issues on a project. I want it to query a MySQL db and list all issues(for individual pages). Ironically it’s for our company website creation. I’m trying to use mysqli and stored procedures for this, and once I get a good handle on that convert the production site to mysqli and stored procedures. One of the issue’s I’m having (I have more questions I’ll most likely post) is I’m not able to pass the correct website page, as a variable, to the stored procedure. What I mean is if I manually put the page name as a string in the call, the query seems to run and create a simple table. If I create a variable with the same string I get an error. Below is my code and the error. At first look I’m assuming this might have something to do with how I have the stored procedure setup. “VARCHAR(255)” and dropping everything after the “.” But I don’t know that much about stored procedures. Everything I’ve done so far did not require passing in a parameter. More info: - The page variable is being populated via a drop down menu, that is created from another query above that gets a list of all pages on the site (stored in another table). Hope that’s not to confusing.. thanx Working: $issues = mysqli_query($connection, "call page_issues(\"ser_ms.php\")"); if (!$issues) { printf("Error: %s\n", mysqli_error($connection)); exit(); } Table created below with the result set separated out.. ****************************** Not working $page = "ser_ms.php"; //$issues = mysqli_query($connection, "call page_issues(\"ser_ms.php\")"); $issues = mysqli_query($connection, "call page_issues($page)"); if (!$issues) { printf("Error: %s\n", mysqli_error($connection)); exit(); } Error I get back is: Error: Unknown table 'ser_ms' in field list Stored Procedure: -- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------------------------------------------------- DELIMITER $$ CREATE PROCEDURE `website`.`page_issues` (IN `cur_page` VARCHAR(255)) BEGIN select * from website_issues where page = cur_page; END
  21. Hy I'm trying to execute this query $stmt = $mysqli->prepare("SELECT streamer,content,provider FROM evento,canali WHERE canali.id=evento.idcanale AND evento.titolo LIKE '%?%' OR evento.sottotitolo LIKE '%?%' AND evento.datainizio=2013-02-21;"); $stmt->bind_param('ss',$tok,$tok); $stmt->execute(); $stmt->close(); but I get this error Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement. but to me it seems like the number are the same, you can see how I prepared the statement with 2 arguments to define, and then I passe 2 arguments to add_param, what I'm getting wrong? some has some ideas? thanks daniele New php-forum User Posts: 2 Joined: Fri May 03, 2013 6:48 pm
  22. I'm fairly new to object orientated PHP and I was trying to think of a better way to connect to a MySQLi database within classes and functions, instead of just putting down an include everywhere. So far I came up with this: database.php <?php class database { protected $db_name = 'database'; protected $db_user = 'root'; protected $db_password = 'password'; protected $db_host = 'localhost'; function __construct(){ $this->connect(); } public function connect(){ $this->db = new mysqli($this->db_host, $this->db_user, $this->db_password, $this->db_name); } } $db = new database; ?> test.php class test{ private function getDb(){ include("database.php"); return $db; } public function test1(){ $find = $this->getDb()->db->query("SELECT * FROM user"); $rows = $find->num_rows; return $rows; } } and then just putting echo $test->test1(); on my page. I did have other functions inside the database class, but I've since scrapped those, so it just looks like that atm. It does work... however, I'm not sure how good or bad it is. In particular the first line in the test1() function. I have a feeling its a terrible way to do it... Or is it fine? like efficiency wise etc? before I would just use an include within every function. so I'd just do: $db->query(" "); Eventually I will have a few classes like user, etc, and these would all need to manipulate the database. So I was just thinking of plopping the getDb() function at the top of each of them and just include the database stuff... I tried looking at how phpBB and wordpress handle databases, but theirs are just full of unnecessary stuff for me and its just difficult to decipher. They use a global I think?
  23. This is my first time converting code in php. I really have no idea what I'm doing and can't tell if i'm doing it right or not. I would appreciate it very much if you could help me. Thanks! From process_new_user.php mysqli if ($insert_stmt = $mysqli-> prepare("INSERT INTO members (username, email, password, salt) VALUES (?, ?, ?, ?)")) { $insert_stmt-> bind_param('ssss', $username, $email, $password, $random_salt); $insert_stmt-> execute(); // Execute the prepared query. echo "<script>"; echo "alert(\"New User Successfully Added!\");"; echo "window.location = \"users.php#current_user\";"; echo "</script>"; } else { echo "alert(\"Uh Oh! Something went terribly wrong.\");"; echo "</script>"; } pdo (attempt) if ($params = array(':username' => $username, ':email' => $email, ':password' => $password, ':random_salt' => $random_salt); $insert_stmt->prepare("INSERT INTO members (username, email, password, salt) VALUES (:username, :email, :password, :random_salt)")) { $insert_stmt-> execute($params); // Execute the prepared query. echo "<script>"; echo "alert(\"New User Successfully Added!\");"; echo "window.location = \"users.php#current_user\";"; echo "</script>"; } else { echo "alert(\"Uh Oh! Something went terribly wrong.\");"; echo "</script>"; } from process_delete_user.php (i converted as much of this as i could. But the last part I have no idea.) original mysqli foreach($id as $check) { $conn = new mysqli(host, user, password, database); if($conn == false){ echo "connection has failed"; } $sql=("DELETE FROM $table WHERE id ='$check'"); $res=mysqli_query($conn, $sql); if($res == true){ echo "<script>"; echo "alert(\"User Successfully Deleted!\");"; echo "window.location = \"users.php#delete_user\";"; echo "</script>"; } else { echo "<script>"; echo "DELETE failed".mysqli_error($conn); // echo "window.location = \"users.php#delete_user\";"; echo "</script>"; } mysqli_close ($conn); } PDO (attempt) foreach($id as $check) { $conn = new PDO(host, database, user, password); if($conn == false){ echo "connection has failed"; } $sql->prepare("DELETE FROM :table WHERE id = :check"); $sql->exectute(array(':username' => $table, ':check' => $check); $res=mysqli_query($conn, $sql); if($res == true){ echo "<script>"; echo "alert(\"User Successfully Deleted!\");"; echo "window.location = \"users.php#delete_user\";"; echo "</script>"; } else { echo "<script>"; echo "DELETE failed".mysqli_error($conn); // echo "window.location = \"users.php#delete_user\";"; echo "</script>"; } mysqli_close ($conn); }
  24. Hi Everyone, I am using the bind_param() function and am building a function around it. I need an automated way of inserting a uncertain (unlimited) amount of parameters into this function. ie have the php code able to insert parameters into the bind_param() function on its own. So if it is given 3 parameters put them in as bind_param($param1,$param2,$param3) or if given 5 parameters bind_param($param1,$param2,$param3,$param4,$param5) I need a way of having the script insert them in for me. What I was thinking was having all of these parameters giving to a function above this as an array. I would then use a foreach loop to determine what type of value each value in this array is and create a string with the appropriate letters to have as the first parameter in the bind_param($value_types ... Then I need a way of cycling through this array and adding how ever many values it has, as individual parameters, to the bind_param() function. Thanks in advance, Timothy
  25. Hello, I am new to mysqli and have a little question. I have tried to find an alternative for a while now but nothing seems to work... maybe somebody could help. So my old code is this function ($email) { $query = mysql_query("SELECT COUNT(`user_id`) FROM users WHERE email = '$email'")or die (mysql_error()); return (mysql_result($query, 0) == 1) ? true : false; } after that the function is used like this : if (login_email_exists($mysqli,$_POST['email']) === true) { $errors[] = 'Sorry this email adress is already in use.'; } And my new code is this function ($mysqli,$email) { $query = $mysqli->query("SELECT COUNT(`user_id`) FROM users WHERE email = '$email'")or die (mysql_error()); return ($query == 1) ? true : false; } Now it seems to always go wrong when I want to check the result and return if it's true or false. If anybody can find an answer or alternative to my problem I would be very happy.
×
×
  • 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.